The role of each jar package in Spring

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
  这个jar文件包含支持缓存Cache(ehcache)、JCA、JMX、邮件服务(Java Mail、COS Mail)、任务计划Scheduling(Timer、Quartz)方面的类。
(11) spring-web.jar
  这个jar文件包含Web应用开发时,用到Spring框架时所需的核心类,包括自动载入WebApplicationContext特性的类、Struts与JSF集成类、文件上传的支持类、Filter类和大量工具辅助类。
(12) spring-webmvc.jar
  这个jar文件包含Spring MVC框架相关的所有类。包含国际化、标签、Theme、视图展现的FreeMarker、JasperReports、Tiles、Velocity、XSLT相关类。当然,如果你的应用使用了独立的MVC框架,则无需这个JAR文件里的任何类。
(13) spring-mock.jar
  这个jar文件包含Spring一整套mock类来辅助应用的测试。Spring测试套件使用了其中大量mock类,这样测试就更加简单。模拟HttpServletRequest和HttpServletResponse类在Web应用单元测试是很方便的。
如何选择这些发布包,决定选用哪些发布包其实相当简单。
 如果你正在构建Web应用并将全程使用Spring,那么最好就使用单个全部的spring.jar文件;
 如果你的应用仅仅用到简单的Inversion of Control / Dependency Injection(IoC/DI)容器,那么只需spring-core.jar与spring-beans.jar即可;
 如果你对发布的大小要求很高,那么就得精挑细选了,只取包含自己所需特性的jar文件了。
采用独立的发布包你可以避免包含自己的应用不需要的全部类。当然你可以采用其它的一些工具来设法令整个应用包变小,节省空间的重点在于准确地找出自己所需的Spring依赖类,然后合并所需的类与包就可以了。
 Eclispe有个插件叫ClassPath Helper可以帮你找找所依赖的类。
Spring包依赖说明:
1) spring-core.jar需commons-collections.jar,spring-core.jar是以下其它各个的基本。
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

一、只是使用spring框架
dist\spring.jar
lib\jakarta-commons\commons-logging.jar

如果使用到了切面编程(AOP),还需要下列jar文件
lib\aspectj\aspectjweaver.jsr 和 aspectjrt.jar
lib\cglib\cglib-nodep-2.1_3.jar

如果使用了JSR-250中的注解如@Resource/@PostConstruct/@PreDestroy
还需下列jar文件
lib\j2ee\common-annotations.jar

二、只是使用spring框架若使用注解方式
只要加一些命名空间和开启解析器
并且@Resource需要加lib\j2ee\common-annotations.jar
<context:annotation-config/>打开处理器

三、要自动扫描
只要开启解析器和一些命名空间
<context:component-scan base-package=""/>

四、spring框架采用aop编程
需要导入一些命名空间
xmlns:aop.......
<aop:aspectj-autoproxy/>开启解析器
如果使用到了切面编程(AOP),还需要下列jar文件
lib\aspectj\aspectjweaver.jsr 和 aspectjrt.jar
lib\cglib\cglib-nodep-2.1_3.jar

五、spring+Jdbc开发
需要数据源文件 lib\jakarta-commons\commons-pool.jar、lib\jakarta-commons\commons-dbcp.jar
1、spring文件 :

dist\spring.jar、
 lib\jakarta-commons\commons-logging.jar
2、jdbc驱动文件 mysql**** sql*** :
导入tx命名空间
<tx:annotation-driven transaction-manager=""/>
对事务注解的解析器

六、spring2.5+hibernate3.3+struts1.3


(1)、hibernate核心包

hibernate3.jar
lib\required\*.jar
lib\optional\ehcache-1.2.3.jar (二级缓存文件)
hibernate注解包
lib\test\slf4j-log4j12.jar

(2)、spring包
dist\spring.jar
lib\jakarta-commons\commons-logging.jar 和commons-pool.jar、commons-dbcp.jar(后为数据源文件)
dist\modules\spring-webmvc-struts.jar (与struts1的集成)
lib\aspectj\aspectjweaver.jsr 和 aspectjrt.jar (Aop文件)
lib\cglib\cglib-nodep-2.1_3.jar     (Aop文件)
lib\j2ee\common-annotations.jar     (注解文件)
lib\log4j\log4j-1.2.15.jar      

(3)、sturs1.3.8
建议将jstl-1.0.2.jar和standard-1.0.2.jar文件更换为1.1版本 此时JSTL文件
还有spring已存在antlr-2.7.6.jar文件所以将struts中的antlr-2.7.6.jar文件删除以免冲突

数据库驱动
mysql*** sql****根据需求换

如果在web容器实例spring容器
加文件到web.xml......

如果action让容器管理,则path(Struts的配置文件)和name(Spring配置文件)要一致
还必须在struts的配置文件里加一个控制器

spring为struts1.3解决乱码问题
在web.xml配置一个filter

七、spring2.5+hibernate3.3+struts2整合开发


struts2文件lib里面所有不带-plugin结尾的jar文件,但除了struts2-spring-plugin-2.0.11.1.jar

Guess you like

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