搭建Maven私服,搭建maven

來源:互聯網
上載者:User

搭建Maven私服,搭建maven

  最近公司人事變革,一批人員被離職,瞬間感覺壓力大增,我一個做android,想要頂起後台介面的活,真是有點吃力,已經30了,還在各種苦逼,但是做為技術控,這種快樂別人無法理解。這幾天Check Out後台代碼,無奈跑不起來,Mac系統Maven構建實在蛋疼,於是恨起來後台組的哥們為什麼不搭建Maven私服,好吧還是交給我來做好了,能者多勞,在這家公司這句話體現的淋漓盡致,廢話不說了,在伺服器上建的已經成功,就隨便找台機子再練習一遍順道寫個日誌。
1、前往http://www.sonatype.com/download-oss-sonatype下載Nexus-Bundle
  :http://www.sonatype.org/downloads/nexus-latest-bundle.zip
2、解壓下載的nexus-2.13.0-01-bundle
  
3、安裝並nexus服務
  更改nexus服務連接埠(可選步驟)
  
  這裡使用預設連接埠 8081
  
5、修改使用者Maven設定檔,%userprofile%\.m2\setting.xml
  
  Content of setting.xml (You should replace `username`,`password` & `url` in the file if you have changed them.)

<servers>    <server>        <id>releases</id>        <username>admin</username>        <password>adminsa</password>    </server>    <server>        <id>snapshots</id>        <username>admin</username>        <password>adminsa</password>    </server></servers><mirrors>    <mirror>        <id>nexus</id>        <mirrorOf>*</mirrorOf>        <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>    </mirror></mirrors><profiles>    <profile>    <id>nexus</id>    <repositories>        <repository>            <id>central</id>            <url>http://central</url>            <releases><enabled>true</enabled></releases>            <snapshots><enabled>true</enabled></snapshots>        </repository>    </repositories>    <pluginRepositories>        <pluginRepository>            <id>central</id>            <url>http://central</url>            <releases><enabled>true</enabled></releases>            <snapshots><enabled>true</enabled></snapshots>        </pluginRepository>    </pluginRepositories>    </profile></profiles><activeProfiles>    <activeProfile>nexus</activeProfile></activeProfiles>

6、用戶端配置(假定已經配置好Maven運行環境)
  為pom.xml添加Maven私服配置
  
  Content of add item

<repositories>    <repository>    <id>nexus</id>    <name>Team Nexus Repository</name>    <url>http://127.0.0.1:8081/nexus/content/groups/public</url>    </repository></repositories><pluginRepositories>    <pluginRepository>    <id>nexus</id>    <name>Team Nexus Repository</name>    <url>http://127.0.0.1:8081/nexus/content/groups/public</url>    </pluginRepository></pluginRepositories>

7、用戶端測試(需要有Maven項目,沒有點擊下載 A Simple Maven Project)
  進入到Maven項目目錄(pom.xml所在目錄)
  
8、驗證Maven私服(Repositories -> Repository Path[Central])
  
9、看到剛剛使用 mvn clean命令下載的plexus-utils-3.0已經在私服倉庫中,這時如果區域網路內其他機器測試就會直接從私服上下載,為項目構建節省資源。
  可以看到在另一台機器上已經下載一上午的結果(Mac系統有時候讓人很無語)
  
  再看看修改了pom.xml後再看看構建是個什麼樣子吧
  
  構建完成,是不是感覺用起來很爽,值得一提的是,其他客戶機上同樣需要在使用者目錄的.m2子目錄中建立setting.xml配置上Maven私服。在Intellij Idea上直接 update indecies還不行,明明已經配置了使用下載的Maven,原因正在調查中。
  

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.