Reputation: 762
I have a relatively simple question regarding spring & hibernate maven builds.
Say I have project A, which has had all jars added to the library by the IDE during project configuration at setup time - there was no Maven POM. Everything in this project is assumed to be working without issue.
Now, take project B. This project will replicate project A, but will be configured using a Maven POM.
My question comes in the dependency configuration stage. Take this image
In order to replicate the lib of Project A, is it required that I manually go through the list of added JARs individually, find the correlating maven dependency at a MVN Repo, and then add them to the project POM of Project B? Or is there a 'neater' way to go about building a basic spring dependency set using maven.
Apologies if this question seems trivial, im a still at the beginner stage of building with Maven POMs.
Many thanks.
Upvotes: 4
Views: 271
Reputation: 772
You would be correct in that there is no currently remained repository (that I know of!) which has "all the spring dependencies". Which is why you would define a Maven property for your Spring version and use it as a placeholder for all your Spring dependencies.
Also, you might not need to add ALL of these JARs, as some of them come along with another one (web comes with webmvc, iirc).
Example: Above (or below) your dependencies, you would use something like this:
<properties>
<spring.version>4.1.5.RELEASE</spring.version>
</properties>
Then, when adding your dependencies, you can use the following:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
Upvotes: 1
Reputation: 8323
I'am afraid the expected way is indeed to find the maven artifact for each dependency.
There is a very nice site for that : http://mvnrepository.com/
Otherwise you can indeed build a "basic spring dependency set" by creating a module with pom packaging listing all your spring dependencies and configure your parent project to depend on this module but there is no real interest to do that IMHO.
Modularity is a wonderful things (jar hell eg. version collision problems is a redundant java application problem and you should keep the finest possible granularity if you want to avoid playing with maven dependency exclusion)
Upvotes: 1
Reputation: 1240
You can use spring-framework-bom as follows:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-framework-bom</artifactId>
<version>4.0.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
...
<dependencies>
Or you can declare a pom property with the spring version:
<properties>
<spring-version>4.0.1.RELEASE</spring-version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring-version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring-version}</version>
</dependency>
...
<dependencies>
You can find the most common dependencies here: http://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/
Upvotes: 1
Reputation: 1565
It was an interesting question for me, but unfortunatly there is no decision (or I can't find it). Look this links:
http://maven.apache.org/ref/3.0.4/maven-model-builder/super-pom.html
http://maven.apache.org/ref/3.0.4/maven-model-builder/
Overriding super POM with a company-wide super/parent POM
Upvotes: 1