1,
项目A 以来项目B, B项目 如果只是执行 clean,package的话,只是打包到B项目的target 下面, 再编译项目A 的时候一览会报编译错误,原因是项目B没有执行install。
所以package 只是打包到target下, install是打包安装到我的本地maven仓库。
2,
deploy: 打包到私服
在setting.xml文件中增加用户名和密码配置(特别注意这里的ID)
<servers> <!-- 用于发布正式版本 --> <server> <id>maven-repository-releases</id> <username>admin</username> <password>admin123</password> </server> <!-- 用于发布快照版本 --> <server> <id>maven-repository-snapshots</id> <username>admin</username> <password>admin123</password> </server> </servers>
2、在项目的pom.xml中增加以下内容
<build> <plugins> <!-- 要将源码放上去,需要加入这个插件 --> <plugin> <artifactId>maven-source-plugin</artifactId> <version>2.1</version> <configuration> <attach>true</attach> </configuration> <executions> <execution> <phase>compile</phase> <goals> <goal>jar</goal> </goals> </execution> </executions> </plugin> </plugins> </build> <distributionManagement> <repository> <!-- 这里的ID要和setting的id一致 --> <id>maven-repository-releases</id> <url>http://ip:8081/nexus/content/repositories/thirdparty/</url> </repository> <!--这是打成快照版本的配置,如果不用这个snapshotRepository标签,打包失败,会报权限问题 --> <snapshotRepository> <id>maven-repository-snapshots</id> <url>http://ip:8081/nexus/content/repositories/thirdparty</url> </snapshotRepository> </distributionManagement>
3.执行Maven build的deploy命令
————摘自其他博文——————
先设置pom文件里的build信息,可以是maven-compiler-plugin插件
maven目录conf的setting.xml里:
- </servers>
- <server>
- <id>releases</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- <server>
- <id>snapshots</id>
- <username>admin</username>
- <password>admin123</password>
- </server>
- </servers>
pom文件添加如下,这里的id上面的id要对应,name无所谓
- <!-- 配置远程发布到私服,mvn deploy -->
- <distributionManagement>
- <repository>
- <id>releases</id>
- <name>Nexus Release Repository</name>
- <url>http://10.1.81.199:8081/nexus/content/repositories/releases/</url>
- </repository>
- <snapshotRepository>
- <id>snapshots</id>
- <name>Nexus Snapshot Repository</name>
- <url>http://10.1.81.199:8081/nexus/content/repositories/snapshots/</url>
- </snapshotRepository>
- </distributionManagement>
没有权限去管理界面查看DeploymentPolicy设置为Allow Redeploy