1. 程式人生 > 其它 >Maven釋出jar包到遠端倉庫

Maven釋出jar包到遠端倉庫

來源《Maven實戰》

在實際專案開發中,有時候需要將我們的專案安裝至公司的私服供其他專案組使用,此時則需要在pom檔案中加如下配置

<distributionManagement>
    <repository>
        <!-- 唯一識別符號 -->
        <id>proj-releases</id>
        <!-- 倉庫名稱 -->
        <name>Proj Release Repository</name>
        <!-- 倉庫地址 -->
        <url>http://
192.168.1.100/content/repository/proj-releases</url> </repository> <snapshotRepository> <id>proj-snapshots</id> <name>Proj Snapshot Repository</name> <url>http://192.168.1.100/content/repository/proj-snapshots</url> </snapshotRepository> </distributionManagement>

如果需要密碼則需要在${MAVEN_HOME}/conf/settings.xml檔案中配置認證

    <server>
      <id>proj-releases</id>  <!-- 與上面私服的倉庫id一致 -->
      <username>repouser</username>
      <password>repopwd</password>
    </server>

配置正確後,在命令列執行

mvn clean deploy