Many people are using spring to develop Java projects, but when configuring Maven dependencies, it is not clear which spring jars to configure, often adding a bunch of random, compiling or running an error to continue configuring Jar dependencies, causing spring to rely on confusion, Even the next time you create the same type of project, you don't know which spring dependencies to configure, only the copy, in fact, that's what I did.
Spring's jar package is only about 20, each with a corresponding function, and a jar may also depend on several other jars, so figuring out the relationship between them makes it straightforward to configure MAVEN dependencies.
Give me a chestnut. To use the spring framework in a normal Java project, you only need to configure Spring-context:
<dependency>
<groupId>org.springframework</groupId>
<artifactid>spring-context </artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
The introduction of Spring MVC in Web engineering. Also, just configure a dependency
<dependency>
<groupId>org.springframework</groupId>
<ARTIFACTID>SPRING-WEBMVC </artifactId>
<version>4.3.2.RELEASE</version>
</dependency>
Why this can be configured. Next we take spring 3 as an example to introduce Spring 4, which is slightly different and will be introduced at the end
The spring website gives a SPRING3 structure:
The diagram divides spring into 5 parts: core, AOP, data access, Web, test, each fillet rectangle in the diagram corresponds to a jar, and if configured in Maven, all of these jar "groupId" are " Org.springframework ", each jar has a different" artifactid ", in addition," instrumentation "has two jars, and a" spring-context-support "graph is not listed, So Spring3 's Jar pack is 19.
The following is a description of the 5-part jar and dependencies:
Core
The core section contains 4 modules Spring-core: The most basic implementation of the dependency injection IOC and DI Spring-beans:bean The context context of the factory and bean Assembly spring-context:spring the IOC container Spring-expression:spring Expression Language
Their full dependencies:
<dependency>
<groupId>org.springframework</groupId>
<artifactid>spring-context </artifactId>
<version>3.2.17.RELEASE</version>
<exclusions>
<exclusion >
<groupId>commons-logging</groupId>
<artifactid>commons-logging</artifactid >
</exclusion>
</exclusions>
</dependency>
Because Spring-core relies on commons-logging, and other modules rely on Spring-core, the entire spring framework relies on commons-logging, if it has its own log implementations such as LOG4J, Can exclude the dependency on commons-logging, no log implementation and exclude the commons-logging dependency, compile error:
<dependency>
<groupId>org.springframework</groupId>
<artifactid>spring-context </artifactId>
<version>3.2.17.RELEASE</version>
<exclusions>
<exclusion >
<groupId>commons-logging</groupId>
<artifactid>commons-logging</artifactid >
</exclusion>
</exclusions>
</dependency>
AOP
The AOP section contains 4 modules SPRING-AOP: Aspect-oriented Programming Spring-aspects: Integrated ASPECTJ spring-instrument: Provides class-level tool support and ClassLoader-level implementations for server SPRING-INSTRUMENT-TOMCAT: Instrument implementation for Tomcat
Their dependencies:
Data Access
The Data Access section contains support for 5 modules SPRING-JDBC:JDBC spring-tx: Transaction control Spring-orm: Object Relational mapping, integrated ORM Framework SPRING-OXM: Object XML mapping Spring-jms:java Messaging Service
Their dependencies:
Web
The Web section contains 4 modules Spring-web: Basic Web features, such as file upload SPRING-WEBMVC:MVC implementation spring-webmvc-portlet: Portlet-based MVC implementation Spring-struts: Integration with struts, not recommended, Spring4 no longer available
Their dependencies:
Test
The test section has only one module, and I'm going to put Spring-context-support in here. Spring-test:spring Test, provides junit and mock test functions Spring-context-support:spring additional support packages, such as mail service, view resolution, etc.
Their dependencies:
Here, Spring3 's introduction is over, look at these diagrams I believe you will not be confused when you configure spring dependencies in Maven
The following describes the Spring4, and the SPRING3 structure is basically the same, the following is the official website given the structure of the chart:
As you can see, the spring3 struts are removed, the messaging and WebSocket are added, the other modules remain the same, so the Spring4 jar has 20 spring-websocket: an efficient communication tool for Web applications Spring-messaging: Used to build message-based applications
Their dependencies:
Citation Source: http://www.importnew.com/22859.html