maven的安装和nexus的安装
1、下载maven3,解压,添加环境变量MAVEN_HOME和path
2、下载nexus2解压,添加环境变量path
3、把D:\dev\mvn\apache-maven-3.0.4\conf下的setting.xml中修改为<localRepository>H:\MavenJar</localRepository>,MavenJar是我的本地仓库
4、建立中央仓库,超级管理员身份运行cmd,执行nexus install
5、修改D:\dev\mvn\nexus-2.1.2\bin\jsw\conf中的wrapper.conf中wrapper.java.command=C:\Program Files\Java\jdk1.6.0_20\bin
6、cmd中执行nexus start,然后浏览器中输入http://localhost:8081/nexus/index.html#welcome
用户名admin,密码admin123
7、配置中央仓库:点击左侧的repository,复制Public Repositories他对应的地址:http://localhost:8081/nexus/content/groups/public/,即为中央仓库的地址
8、在parent的pom.xml中配置:
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<layout>default</layout>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
9、配置镜像:设置私有工厂一般要配置镜像
在mvn的setting.xml中的<mirrors>里面添加:
<mirror>
<id>central</id>
<mirrorOf>*</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>http://localhost:8081/nexus/content/repositories/central</url>
</mirror>
这里面的*表示parent的pom.xml中所有的repository添加配置,我的里面只有一个nexus
10、把lucence创建的nexus索引文件拷贝到D:\dev\mvn\sonatype-work\nexus\indexer\central-ctx中,先清空,也要先nexus stop。
二。maven创建项目
创建一个简单的maven项目的命令如下:
mvn archetype:create -DgroupId=com.luo -DartifactId=plat-DpackageName=com.luo -DarchetypeArtifactId=maven-archetype-artifactId=webapp
DpackageName可省略不写