61

Spring核心模块及功能汇总

 5 years ago
source link: http://www.choupangxia.com/topic/detail/130?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

如果你在使用Spring,而且没有使用SpringBoot,那么每个Spring的功能都需要引入相应的jar包依赖。而Spring的jar包依赖又有一二十个,很容易混淆,造成编译或运行错误。

下面我们就整理一下Spring3和Spring4的核心模块和对应的jar包,方便我们在具体使用的过程中更加清晰的了解到我们都需要什么。

Spring3框架结构图

2QNNza6.jpg!web

Spring4框架结构图

uIvU7rj.jpg!web 与Spring3相比去掉了Struts,新增了Messaging和Websocket。

分析上面的框架结构图,大概包括以下模块和jar包依赖。

核心容器(Core Container)

  • spring-core:核心类库,其他模块大量使用此jar包;
  • spring-beans:Spring定义Bean的支持;
  • spring-context:运行时Spring容器;
  • spring-context-support:Spring容器对第三方包的集成支持,比如邮件服务、视图解析
  • spring-expression:Spring表达式语言

AOP

  • spring-aop:基于代理的AOP支持;
  • spring-aspects:基于AspectJ的AOP支持;
  • spring-instrument:提供一些类级的工具支持和ClassLoader级的实现,用于服务器;
  • spring-instrument-tomcat:针对tomcat的instrument实现;

数据访问/集成

  • spring-jdbc:提供以jdbc访问数据库的支持;
  • spring-tx:提供编程式和声明式事务支持;
  • spring-orm:提供对象/关系映射支持;
  • spring-oxm:提供对象/xml映射支持;
  • spring-jms:提供对JMS(java消息服务)的支持;

web

  • spring-web:提供基础的web集成功能;
  • spring-webmvc:基于servlet的MVC;
  • spring-webmvc-portlet:基于portlet的mvc实现;
  • spring-websocket:提供websocket功能;

test&messaging

  • spring-test:spring测试,提供junit与mock测试功能;
  • spring-messaging:对消息架构和协议的支持;

当我们清晰明了的知道Spring的每个模块都需要引入什么jar包时,出错的概率也将大大减少,当然,如果能够使用Springboot,问题将会更加简化。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK