SpringFramework的Maven设置

现在,SpringFramework已开发到了3.0.0.M3版本,可以直接通过Maven使用。要在Maven中使用SpringFramework,首先要在POM.xml文件中加入如下的依赖关系:

<dependencies>
     <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>org.springframework.core</artifactId>
         <version>3.0.0.M3</version>
     </dependency>
 </dependencies>

其次,是配置SpringFramework的下载位置,同样在POM.xml中加入如下的代码:

<repositories>
     <repository>
         <id>SpringSource Enterprise Bundle Repository - External Bundle Milestones</id>
         <url>http://repository.springsource.com/maven/bundles/milestone</url>
     </repository>
     <repository>
         <id>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</id>
         <url>http://repository.springsource.com/maven/bundles/release</url>
     </repository>
     <repository>
         <id>SpringSource Enterprise Bundle Repository - External Bundle Releases</id>
         <url>http://repository.springsource.com/maven/bundles/external</url>
     </repository>
 </repositories>

注意,这里,我们只添加了org.springframework.core的依赖关系,SpringFramework的其它组件也可以通过类似的方法添加。至于SpringFramework有哪些组件,可以通过下面的链接查看:

上面的链接是查看3.0版本的组件,如果要查看2.5版本的组件,可以通过下面的链接:

可以看出,由于3.0还没有正式释出,所有是通过milestone访问的,以后正式释出后,也可能会移到release中。

另外,如果我们不想一个组件一个组件的添加,想直接使用所有的SpringFramework,也可以添加整个库的依赖关系:

<dependency>
     <groupId>org.springframework</groupId>
     <artifactId>org.springframework.spring-library</artifactId>
     <type>libd</type>
     <version>3.0.0.M3</version>
 </dependency>

相应的下载位置设置如下:

<repository>
     <id>SpringSource Enterprise Bundle Repository - Library Milestones</id>
     <url>http://repository.springsource.com/maven/libraries/milestone</url>
 </repository>
经验分享 程序员 微信小程序 职场和发展