1. The content of the article is summarized:
The spring framework is MAVEN-enabled, because the jar packages packaged by all the modules of the spring framework and other jar packages that spring relies on are stored in a central Maven repository, and if your project is managed using MAVEN, Then you can use MAVEN in your project to introduce the spring-related jar packages or other dependent libraries that your project relies on.
MAVEN-related things in the 2.spring framework:
Overview: Using MAVEN to manage spring-related jar packages, you need to configure GroupID, Artifactid, and so on in Pom.xml, and Maven will find Maven's local repository for your project only if these things are configured in Pom.xml--- > Central Warehouse---> Other remote repositories, download the relevant jar packages that the update project relies on to your local repository.
-
- GroupId is
org.springframework
.
- Artifactid See table below
GroupId |
Artifactid |
Description |
Org.springframework |
Spring-aop |
proxy-based AOP Support |
Org.springframework |
Spring-aspects |
AspectJ based aspects |
Org.springframework |
Spring-beans |
Beans support, including Groovy |
Org.springframework |
Spring-context |
Application context runtime, including scheduling and remoting abstractions |
Org.springframework |
Spring-context-support |
Support classes-integrating common third-party libraries into a Spring application context |
Org.springframework |
Spring-core |
Core utilities, used by many and other Spring modules |
Org.springframework |
Spring-expression |
Spring Expression Language (spel) |
Org.springframework |
Spring-instrument |
Instrumentation agent for JVM bootstrapping |
Org.springframework |
Spring-instrument-tomcat |
Instrumentation agent for Tomcat |
Org.springframework |
Spring-jdbc |
JDBC Support package, including DataSource setup and JDBC Access support |
Org.springframework |
Spring-jms |
JMS support package, including helper classes to send and receive JMS messages |
Org.springframework |
Spring-messaging |
Support for messaging architectures and protocols |
Org.springframework |
Spring-orm |
Object/relational Mapping, including JPA and Hibernate support |
Org.springframework |
Spring-oxm |
Object/xml Mapping |
Org.springframework |
Spring-test |
Support for unit testing and integration testing Spring components |
Org.springframework |
Spring-tx |
Transaction infrastructure, including DAO support and JCA integration |
Org.springframework |
Spring-web |
Web support packages, including client and web remoting |
Org.springframework |
Spring-webmvc |
REST Web Services and Model-view-controller implementation for Web applications |
Org.springframework |
Spring-webmvc-portlet |
MVC implementation to being used in a Portlet environment |
Org.springframework |
Spring-websocket |
WebSocket and SOCKJS implementations, including STOMP support |
3. Use Maven to add spring-related jar packages to my project in your project
Overview: The spring-related jar packages that are dependent on using MAVEN to add projects to their own projects are available in a number of ways, with detailed descriptions of the various methods described below
3.1 Method One, add the jar package corresponding to the corresponding module of the spring Framework in the MAVEN central warehouse directly, the configuration method is as follows:
Pom.xml
<Dependencies> <Dependency> <groupId>Org.springframework</groupId><!--See the second part of this article -- <Artifactid>Spring-context</Artifactid><!--See the second part of this article: Table -- <version>4.3.4.RELEASE</version><!--Spring-related modules corresponding to the JAR package version-- <Scope>Runtime</Scope><!--Note The scope can be declared as runtime if you don ' t need to compile against Sprin G APIs, which is typically the case for basic dependency injection use cases.--> </Dependency></Dependencies>
3.2 Method Two, instead of downloading from the MAVEN central repository, download the spring framework-related jar package to the MAVEN local repository from other remote repositories (this is the Spring Maven repository site), which is configured as follows
Overview: the example above works with the Maven central repository. To use the Spring Maven repository (e.g-Milestones or developer snapshots), you need to specify the repository Locati On your Maven configuration.
Specific configuration method: as follows, configure the Pom.xml file
Pom.xml
For full releases:
<repositories> <Repository> <ID>Io.spring.repo.maven.release</ID> <URL>http://repo.spring.io/release/</URL> <Snapshots><enabled>False</enabled></Snapshots> </Repository></repositories>
For milestones:
<repositories> <Repository> <ID>Io.spring.repo.maven.milestone</ID> <URL>http://repo.spring.io/milestone/</URL> <Snapshots><enabled>False</enabled></Snapshots> </Repository></repositories>
And for snapshots:
<repositories> <Repository> <ID>Io.spring.repo.maven.snapshot</ID> <URL>http://repo.spring.io/snapshot/</URL> <Snapshots><enabled>True</enabled></Snapshots> </Repository></repositories>
3.3 Method Three, Maven "Bill of Materials" Dependency
Overview:
It is possible to accidentally mix different versions for Spring JARs when using Maven. For example, the Third-party library, or another Spring project, pulls in a transitive dependency to an OL Der Release. If you forget to explicitly declare a direct dependency yourself, all sorts of unexpected issues can arise.
To overcome such problems Maven supports the concept of a "Bill of Materials" (BOM) dependency. You can import the on your section to spring-framework-bom
dependencyManagement
ensure, all spring dependencies (both direct and transitive) is at t He same version.
<dependencymanagement> <Dependencies> <Dependency> <groupId>Org.springframework</groupId> <Artifactid>Spring-framework-bom</Artifactid> <version>4.3.4.RELEASE</version> <type>Pom</type> <Scope>Import</Scope> </Dependency> </Dependencies></dependencymanagement>
An added benefit of the using the BOM are that you no longer need to specify the <version>
attribute when depending on Spring Fram Ework Artifacts:
<Dependencies> <Dependency> <groupId>Org.springframework</groupId> <Artifactid>Spring-context</Artifactid> </Dependency> <Dependency> <groupId>Org.springframework</groupId> <Artifactid>Spring-web</Artifactid> </Dependency><Dependencies>
The third part of the summary: through the above content we can find that using MAVEN to our software project to add spring each module corresponding to the jar package and spring depends on the jar package a total of two methods, The first approach is to configure Pom.xml to download spring-related jar packages from the MAVEN central repository to the MAVEN local repository, where elements such as GroupID, Artifactid, etc. The second method is to configure the Pom.xml to manage spring-related jar packages from the spring remote repository instead of MAVEN's central repository, download from the Spring remote repository instead of downloading the spring-related jar packages that the project relies on from the MAVEN central repository to the computer Maven local repository. It is possible to manage the spring-related jar packages that the project relies on using both of these methods, but regardless of which method you use, be aware of the version conflict of the jar packages for each of the spring modules. For example, it is possible that your spring-context-4.3.4.release.jar, but the Spring-web module related jar package is configured as 3.4.3.release.jar, the version is inconsistent, it is possible to cause errors in the operation process, in order to avoid the spring between different modules Consistent issue, you can use the third section of this chapter: "3.3 Method Three, Maven" Bill of Materials "Dependency" described in the method configuration Pom.xml
The Java Framework-----The Spring framework------How to manage spring-related jar packages with Maven in their own projects