The role of Spring's jar packages

  spring.jar is a single jar package that contains a complete release. spring.jar contains the contents of all other jar packages except those contained in spring-mock.jar, because spring-mock is only used in the development environment .jar for auxiliary testing, these classes are not used in formal application systems.

  
   In addition to the spring.jar file, Spring also includes 13 other independent jar packages, each of which contains the corresponding Spring components. Users can choose and combine their own jar packages according to their own needs without introducing all the classes of the entire spring.jar. document.
  (1) spring-core.jar
    This jar file contains the basic core tool classes of the Spring framework. The classes in this package must be used by other Spring components. They are the basic core of other components. Of course, you can also use these tool classes in your own application system.
  (2) spring-beans.jar
    This jar file is used by all applications, and it contains all classes related to accessing configuration files, creating and managing beans, and performing Inversion of Control / Dependency Injection (IoC/DI) operations. If the application only needs basic IoC/DI support, you can import the spring-core.jar and spring-beans.jar files.
  (3) spring-aop.jar
    This jar file contains the classes required to use Spring's AOP features in an application. Use AOP-based Spring features, such as Declarative Transaction Management, and include this jar in your application.
  (4) spring-context.jar
    This jar file provides a number of extensions to the Spring core. You can find all the classes needed to use the Spring ApplicationContext feature, all the classes needed by JDNI, the UI classes used to integrate with templating engines such as Velocity, FreeMarker, JasperReports, and the related classes for validation.
  (5) spring-dao.jar
    This jar file contains all classes for data access by Spring DAO, Spring Transaction. In order to use declarative transaction support, you also need to include spring-aop.jar in your application.
  (6) spring-hibernate.jar
    This jar file contains all the classes that Spring encapsulates for Hibernate 2 and Hibernate 3.
  (7) spring-jdbc.jar
    This jar file contains all the classes that encapsulate Spring's JDBC data access.
  (8) spring-orm.jar
    This jar file contains Spring's extension of the DAO feature set to support iBATIS, JDO, OJB, and TopLink, because Hibernate has been packaged independently and is now not included in this package. Most of the classes in this jar file depend on the classes in spring-dao.jar. When using this package, you need to include the spring-dao.jar package at the same time.
  (9) spring-remoting.jar
    This jar file contains classes that support EJB, JMS, Remote Call Remoting (RMI, Hessian, Burlap, Http Invoker, JAX-RPC).
  (10) spring-support.jar
    This jar file contains classes that support caching (ehcache), JCA, JMX, mail services (Java Mail, COS Mail), and task scheduling (Timer, Quartz).
  (11) spring-web.jar
    This jar file contains the core classes required when using the Spring framework during Web application development, including classes that automatically load the WebApplicationContext feature, Struts and JSF integration classes, file upload support classes, Filter classes, and a large number of tool auxiliary classes.
  (12) spring-webmvc.jar
    This jar file contains all classes related to Spring MVC framework. Contains FreeMarker, JasperReports, Tiles, Velocity, and XSLT related classes for internationalization, tags, Theme, and view presentation. Of course, if your application uses a standalone MVC framework, you don't need any of the classes in this JAR file.
  (13) spring-mock.jar
    This jar file contains Spring's complete set of mock classes to aid in application testing. The Spring test suite uses a large number of mock classes to make testing easier. Mocking the HttpServletRequest and HttpServletResponse classes is handy for unit testing web applications.
 

How to choose these distributions and decide which distributions to use:

   If you are building a web application and will be using Spring throughout, it is best to use a single all-in-one spring.jar file;
   If your application only uses a simple Inversion of Control / Dependency Injection (IoC/DI) container, then you only need spring-core.jar and spring-beans.jar;
   If you have high requirements on the size of the distribution, then you have to choose carefully and only take the jar files that contain the features you need.
  By using a separate distribution you can avoid including all the classes that your application doesn't need. Of course, you can use other tools to try to make the entire application package smaller. The key to saving space is to find out exactly the Spring dependency classes you need, and then merge the required classes and packages.
   Eclispe has a plugin called ClassPath Helper that can help you find dependent classes.

Spring package dependency description:

  1) spring-core.jar requires commons-collections.jar, spring-core.jar is the basis of the following others.
  2) spring-beans.jar需spring-core.jar,cglib-nodep-2.1_3.jar
  3) spring-aop.jar需spring-core.jar,spring-beans.jar,cglib-nodep-2.1_3.jar,aopalliance.jar
  4) spring-context.jar需spring-core.jar,spring-beans.jar,spring-aop.jar,commons-collections.jar,aopalliance.jar
  5) spring-dao.jar需spring-core.jar,spring-beans.jar,spring-aop.jar,spring-context.jar
  6) spring-jdbc.jar需spring-core.jar,spring-beans.jar,spring-dao.jar
  7) spring-web.jar需spring-core.jar,spring-beans.jar,spring-context.jar
  8) spring-webmvc.jar需spring-core.jar/spring-beans.jar/spring-context.jar/spring-web.jar
  9) spring-hibernate.jar需spring-core.jar,spring- beans.jar,spring-aop.jar,spring-dao.jar,spring-jdbc.jar,spring- orm.jar,spring-web.jar,spring-webmvc.jar
  10) spring-orm.jar需spring-core.jar,spring-beans.jar,spring-aop.jar,spring-dao.jar,spring-jdbc.jar,spring-web.jar,spring-webmvc.jar
  11) spring-remoting.jar需spring-core.jar,spring-beans.jar,spring- aop.jar,spring-dao.jar,spring-context.jar,spring-web.jar,spring- webmvc.jar
  12) spring-support.jar需spring-core.jar,spring-beans.jar,spring-aop.jar,spring-dao.jar,spring-context.jar,spring-jdbc.jar
  13) spring-mock.jar需spring-core.jar,spring-beans.jar,spring-dao.jar,spring-context.jar,spring-jdbc.jar

1. Just use the spring framework

dist\spring.jar
lib\jakarta-commons\commons-logging.jar

If you use Aspect Programming (AOP), you also need the following jar files
lib\aspectj\aspectjweaver.jsr and aspectjrt.jar
lib\cglib\cglib-nodep-2.1_3.jar

If you use annotations in JSR-250 such as @Resource/@PostConstruct/@PreDestroy
, the following jar file
lib\j2ee\common-annotations.jar is required

2. Just use the spring framework if you use the annotation method

Just add some namespaces and enable the parser
and @Resource needs to add lib\j2ee\common-annotations.jar
<context:annotation-config/> to enable the processor

3. To scan automatically

Just turn on the parser and some namespace
<context:component-scan base-package=""/>

Fourth, the spring framework uses aop programming

Need to import some namespaces
xmlns:aop.......
<aop:aspectj-autoproxy/> to open the parser
If you use Aspect Programming (AOP), you also need the following jar files
lib\aspectj\aspectjweaver.jsr and aspectjrt. jar
lib\cglib\cglib-nodep-2.1_3.jar

Five, spring+Jdbc development

Need data source files lib\jakarta-commons\commons-pool.jar, lib\jakarta-commons\commons-dbcp.jar
1. Spring file:

dist\spring.jar,
 lib\jakarta-commons\commons-logging.jar
2, jdbc driver file mysql**** sql***:
import tx namespace
<tx:annotation-driven transaction-manager=""/>
A parser for transaction annotations

 

This article is transferred from the network

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324868218&siteId=291194637