Spring Starter Guide: Understanding how Spring is packaged

Source: Internet
Author: User
Tags aop contains include versions
Packaged

After getting the Spring release package, you might be surprised to discover that the spring development team did not use a single jar file to contain all the code, but instead chose to build a single jar and 8 separate jar files with a full release to contain the corresponding spring components. The number of future versions of the component jar files is likely to increase, making it easier for you to choose the features you want your code to contain.

Full Release Package

All release versions provide Spring.jar files, which almost contain the full release package for the spring framework classes. "Almost" because it doesn't actually contain any mock classes, these classes are published with spring as a secondary test. This is a wise decision of the spring development team because you almost never need to distribute mock classes at the same time when publishing applications, and you are only using them in the development environment to aid the testing process. In addition, the Spring.jar file contains all the other classes in the spring main source tree.

Component Publishing Package

In addition to Spring.jar files, spring includes the other 8 jar files mentioned earlier, one of which contains mock classes and the other seven separate components that contain the spring framework. The jar files are listed in table 2-1 and are accompanied by a description of the corresponding components.

Table 2-1:spring Component Publishing Package

JAR file Description
Spring-aop.jar This jar file contains all the classes you need to use the AOP features of spring in your application. If you intend to use other AOP-based spring features, such as declarative transaction management (declarative transaction management), you will also need to include this jar file in your application.
Spring-context.jar The classes in this package provide a large number of extensions to the spring core. You can find all the classes you need to use the Spring ApplicationContext feature (described in chapter 5th), and the classes you need to support EJB, Jndi, and messaging integration. In addition, the package includes the spring Remote Call (remoting) class, which is used to integrate with the template (templating) engine such as velocity and freemarker, and to validate the base validation class. It is worth noting that in fact many classes are not too appropriate to be included in this package, such as remote invocation and EJB support features such as the packaging of a separate jar file is more appropriate.
Spring-core.jar All applications use this JAR file, which contains all the classes that are related to accessing the configuration file, creating and managing the bean, and doing the di operation. If your application requires only basic di support, the jar file is sufficient to meet your needs. In addition, the jar file contains a very useful set of tool classes, which are used extensively by the spring code library and can be used in their own applications.
Spring-dao.jar This JAR file contains

Spring-mock.jar As mentioned earlier, Spring provides a complete set of mock classes to assist in the application of tests. The Spring test suite uses a large number of mock classes, so they have been tried and tested to make your application test simpler. The great usefulness of mock httpservletrequest and HttpServletResponse classes in Web application unit tests is needless to mention.
Spring-orm.jar This jar file extends spring's standard DAO feature set to support Hibernate, Ibatis, and JDO. The large number of classes in this jar file depend on the class in the Spring-dao.jar, and there is no doubt that you need to include the latter. Each ORM tool may be packaged separately in the future, so that when you use Ibatis, your application eliminates the need to include Hibernate and JDO-related classes.
Spring-web.jar This jar file contains the core classes required for Web applications to use spring, including classes that automatically load the ApplicationContext attribute, struts integration classes, support classes for file uploads, and a large number of helper classes. A task used to perform repetitive tasks such as the int value in the parse query string.
Spring-webmvc.jar This jar file contains all the classes associated with the Spring MVC framework. If your application uses a separate MVC framework, you do not need any of the classes in this jar file. The 18th chapter gives a more detailed introduction to spring MVC.

How to select a publishing package

Deciding which release packs to choose is actually fairly straightforward. If you are building Web applications and will use spring throughout, it is best to use Spring.jar files so that you don't get bogged down in maintaining different files. Similarly, if your application uses just a simple di container, it can be done with just spring-core.jar. If you have a high demand for the size of your publication, you should choose to select only the jar files that contain the features you want.

Note that the granularity of the above component release packages is actually not that small, but you can at least avoid including all the classes that your application doesn't need (or it will contain unwanted classes). Maybe you can try to make the whole application a little bit smaller, but the key to space saving is how to pinpoint the spring dependencies you need, and the rest of them will abandon them.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.