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 a project of the same type, 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, a jar may also rely on a number of other jars, so to understand the relationship between them, configuration maven dependency can be concise, for example, to use the spring framework in a common Java project, Which jars do you need? As long as a
12345 |
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version> 3.2 . 17 .RELEASE</version> </dependency> |
What about the introduction of Spring MVC in Web engineering? Also, just configure a dependency
12345 |
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version> 3.2 . 17 .RELEASE</version> </dependency> |
Why can I configure this? Next we take the spring 3.2.17.RELEASE version as an example of the spring framework structure, Spring 4 slightly different, will be introduced in the last
The spring website gives a picture of the 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
Core section contains 4 modules
- Spring-core: The most basic implementation of dependency injection IOC and DI
- Spring-beans:bean Factory and Bean Assembly
- Spring-context:spring context is the IOC container
- Spring-expression:spring Expression Language
Their complete dependencies
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
1234567891011 |
<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 consists of 4 modules
- SPRING-AOP: Plane-oriented programming
- Spring-aspects: Integrated ASPECTJ
- Spring-instrument: Provides class-level tooling support and ClassLoader-level implementations for server
- SPRING-INSTRUMENT-TOMCAT: Instrument implementation for Tomcat
They depend on the relationship
Data access
The data Access section consists of 5 modules
- SPRING-JDBC:JDBC's support
- SPRING-TX: Transaction control
- Spring-orm: Object Relational mapping, integrated ORM Framework
- SPRING-OXM: Object XML mappings
- Spring-jms:java Messaging Service
They depend on the relationship
Web
The Web section contains 4 modules
- Spring-web: Basic Web features, such as file uploads
- SPRING-WEBMVC:MVC implementation
- Spring-webmvc-portlet: A portlet-based MVC implementation
- Spring-struts: Integration with struts, not recommended, Spring4 no longer available
They depend on the relationship
Test
The test section has only one module, and I'll put the spring-context-support 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.
They depend on the relationship
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 is the introduction of Spring4, and the SPRING3 structure is basically the same, the following is the official website of the structure diagram
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
They depend on the relationship
Maven dependencies between the Spring framework architecture and the internal module jars