If you use Maven, choose one of two repositories from which to obtain the Spring jars:
Maven Central, which is the default repository Maven queries, and does not require special configuration
Enterprise Bundle Repository (EBR), which is run by SpringSource and also hosts all the libraries that integrate with Spring
In general, if you care about OSGi, use the EBR, because it houses OSGi-compatible artifacts for all of Spring's dependencies, such as Hibernate and Freemarker. If OSGi does not matter to you, either option works. Choose one place or the other for your project; do not mix them. This is particularly important because EBR artifacts use a different naming convention from Maven Central artifacts.
The following table compares Maven Central to the EBR:
Table 2.2.
Feature | Maven Central | Enterprise Bundle Repository (EBR) |
OSGi-compatible | No. | Yes. |
Number of artifacts | Tens of thousands; all kinds. | Hundreds; those that Spring integrates and supports. |
Consistent naming conventions for all artifacts? | No. | Yes. |
Artifact naming convention | Group id: Varies. Newer artifacts use domain name, for example, org.sl4j; older artifacts use artifact id, for example, log4j. Artifact id: Varies. Typically the JAR file name minus extension, for example,log4j. Version: Varies. Most use numbers and periods, for example, 3.0.0. | Group id: <Domain name> such as org.springframework. Artifact id: <Bundle-SymbolicName>, derived from main package, for example, org.springframework.beans. If the JAR had to be patched to ensure OSGi compliance, com.springsource. is prepended, for example, com.springsource.org.apache.log4j. Version: OSGi version number format of <major>.<minor>.<micro>[.qualifier], for example, 3.0.0.RELEASE. |
Publishing | Automatic (rSync via remote repositories). | Manual (JIRA processed by SpringSource). |
Quality assurance | Accuracy is responsibility of publishing organization. | Extensive (for both MANIFEST.mf and .pom); QA is performed by Spring Team. |
Hosting | At Contegix funded by Sonatype with several mirrors. | Amazon S3 funded by SpringSource. |
Search utilities | Various | http://www.springsource.com/repository |
Integrated with SpringSource Tools (STS, Roo, CloudFoundry) | Yes, with STS. | Yes, with STS, Roo, and CloudFoundry. |
You do not have to add a repository to your .pom to obtain final releases of Spring projects from Maven Central. Simply add the dependencies your project requires. A .pom <dependency> snippet for each Spring Framework 3 artifact as it will be indexed in Maven Central is listed below.
<!-- Core utilities used by other modules. Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Expression Language (depends on spring-core) Define this if you use Spring Expression APIs (org.springframework.expression.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Bean Factory and JavaBeans utilities (depends on spring-core) Define this if you use Spring Bean APIs (org.springframework.beans.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-beans</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Aspect Oriented Programming (AOP) Framework (depends on spring-core, spring-beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Application Context (depends on spring-core, spring-expression, spring-aop, spring-beans) This is the central artifact for Spring's Dependency Injection Container and is generally always defined --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration Define this if you need any of these integrations --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Transaction Management Abstraction (depends on spring-core, spring-beans, spring-aop, spring-context) Define this if you use Spring Transactions or DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- JDBC Data Access Library (depends on spring-core, spring-beans, spring-context, spring-tx) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis. (depends on spring-core, spring-beans, spring-context, spring-tx) Define this if you need ORM (org.springframework.orm.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans. (depends on spring-core, spring-beans, spring-context) Define this if you need OXM (org.springframework.oxm.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Web application development utilities applicable to both Servlet and Portlet Environments (depends on spring-core, spring-beans, spring-context) Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Spring MVC for Servlet Environments (depends on spring-core, spring-beans, spring-context, spring-web) Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Spring MVC for Portlet Environments (depends on spring-core, spring-beans, spring-context, spring-web) Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc-portlet</artifactId> <version>3.0.0.RELEASE</version> </dependency>
To obtain final releases of Spring projects from the EBR, add the following repositories to your .pom:
<repository> <id>com.springsource.repository.bundles.release</id> <name>EBR Spring Release Repository</name> <url>http://repository.springsource.com/maven/bundles/release </url> </repository> <repository> <id>com.springsource.repository.bundles.external</id> <name>EBR External Release Repository</name> <url>http://repository.springsource.com/maven/bundles/external </url> </repository>
Then simply add the dependencies your project requires, keeping in mind the EBR artifact naming conventions.
A .pom <dependency> snippet for each Spring Framework 3 artifact as it will be indexed in the EBR is listed below:
<!-- Core utilities used by other modules. Define this if you use Spring Utility APIs (org.springframework.core.*/org.springframework.util.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.core</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Expression Language (depends on core) Define this if you use Spring Expression APIs (org.springframework.expression.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.expression</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Bean Factory and JavaBeans utilities (depends on core) Define this if you use Spring Bean APIs (org.springframework.beans.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.beans</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Aspect Oriented Programming (AOP) Framework (depends on core, beans) Define this if you use Spring AOP APIs (org.springframework.aop.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.aop</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Application Context (depends on core, expression, aop, beans) This is the central artifact for Spring's Dependency Injection Container and is generally always defined --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.context</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Various Application Context utilities, including EhCache, JavaMail, Quartz, and Freemarker integration Define this if you need any of these integrations --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.context.support</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Transaction Management Abstraction (depends on core, beans, aop, context) Define this if you use Spring Transactions or DAO Exception Hierarchy (org.springframework.transaction.*/org.springframework.dao.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.transaction</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- JDBC Data Access Library (depends on core, beans, context, transaction) Define this if you use Spring's JdbcTemplate API (org.springframework.jdbc.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.jdbc</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Object-to-Relation-Mapping (ORM) integration with Hibernate, JPA, and iBatis. (depends on core, beans, context, transaction) Define this if you need ORM (org.springframework.orm.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.orm</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Object-to-XML Mapping (OXM) abstraction and integration with JAXB, JiBX, Castor, XStream, and XML Beans. (depends on core, beans, context) Define this if you need OXM (org.springframework.oxm.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.oxm</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Web app development utilities common across Servlet/Portlet environments (depends on core, beans, context) Define this if you use Spring MVC, or wish to use Struts, JSF, or another web framework with Spring (org.springframework.web.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.web</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Spring MVC for Servlet Environments (depends on core, beans, context, web) Define this if you use Spring MVC with a Servlet Container such as Apache Tomcat (org.springframework.web.servlet.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.web.servlet</artifactId> <version>3.0.0.RELEASE</version> </dependency> <!-- Spring MVC for Portlet Environments (depends on core, beans, context, web) Define this if you use Spring MVC with a Portlet Container (org.springframework.web.portlet.*) --> <dependency> <groupId>org.springframework</groupId> <artifactId>org.springframework.web.portlet</artifactId> <version>3.0.0.RELEASE</version> </dependency>
Spring tools can be useful for projects that use Maven. Both the SpringSource Tool Suite and Spring Roo provide wizards that can generate new Spring projects with pre-configured .poms. Roo can actually manage your .pom for you as you execute code generation commands that require additional artifacts to be downloaded. Cloud Foundry also has a new capability that allows cloud deployments to be made without external dependencies, greatly reducing deployment times. To make this work, Cloud Foundry syncs with the EBR after publishing to complete a deployment.