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