maven之 第一个项目构建



 在看maven官网中的配置setting.xml,里面内容一头雾水,如果不实践下,就不知所云了。下面操作

The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information.

There are two locations where a settings.xml file may live:

  • The Maven install: $M2_HOME/conf/settings.xml
  • A user’s install: ${user.home}/.m2/settings.xml

The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged, with the user-specific settings.xml being dominant.

上面主要是说,配置settings.xml有2个文件,一个在环境目录下,也就是maven下载解压包的目录下面,还有一个就是用户根目录下,也就是C盘用户下-m2

如果2个目录下都存在settings.xml配置文件,那么他们会合并,而且是用户目录下的配置文件优先

 1 本地仓库配置,默认是在${user.home}/.m2/repository

<settingsxmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0
 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>${user.home}/.m2/repository</localRepository>
<interactiveMode>true</interactiveMode>
<usePluginRegistry>false</usePluginRegistry>
<offline>false</offline>
 ...
</settings>

 

由于C盘不适合放除操作系统外的系统文件数据,所以我们要将它放在其他盘,可以修改标签localRepository的值,可以复制解压好的maven目录下的setting文件到D:/m2下

这里改成 <localRepository>D:/m2/repository</localRepository>

注意:m2目录下再放个repository,是存放jar包等文件的仓库

扫描二维码关注公众号,回复: 479697 查看本文章

 

在某个目录下输入命令 mvn  -install 之后,会看到一些文件的下载信息。

之后可以看到目录如下

 

一些必要的jar包都已经下载到仓库中了,也说明了本地仓库已经配置正确

二  建立第一个maven项目

首先在d盘建一个文件如maven demo,然后直接通过命令输入

mvn archetype:generate,可以根据提示创建maven文件

三  第二种 参考

http://my.oschina.net/summerpxy/blog/187447

http://my.oschina.net/qjx1208/blog/201085
 

猜你喜欢

转载自zhizhi555555.iteye.com/blog/2229202