spring学习2-工程的pom.xml配置

pom.xml是maven的东西,由于现在spring的包管理都用这个,我就顺便学习一下简单的使用。

在上篇博客中,我使用了maven的quitestart模版,在工程的目录下就自动生成了一个pom.xml,打开xml可以看到里面的信息很简单,最上方是工程的基本信息,有之前填写的groupid, artifactid,我主要用到的是下面管理包依赖关系的dependencies

   
   
   
   
< dependencies > < dependency > < groupId > junit </ groupId > < artifactId > junit </ artifactId > < version > 3.8.1 </ version > < scope > test </ scope > </ dependency > </ dependencies >

可以看到,默认maven为我们添加了junit的包引用,这里我们添加一下spring的基本包。在官方的文档上,可以找到依赖的例子,我改了一下版本号,使用大多数人都在用的3.2.8,最新的版本是4.0.2

   
   
   
   
< dependencies > < dependency > < groupId > org.springframework </ groupId > < artifactId > spring-context </ artifactId > < version > 3.2.8.RELEASE </ version > < scope > runtime </ scope > </ dependency > </ dependencies >

添加完保存后,maven就会自动去下载相应的包了。

image

 

备注:

maven依赖包的地址查找

http://mvnrepository.com/

你可能感兴趣的:(spring学习2-工程的pom.xml配置)