分享

关于nexus

 碧海山城 2010-05-29

我对比了一些maven的私服以后,感觉nexus最好使,把搭建的过程步骤一下吧,我的环境是cent5, tomcat 6
1、下载war包,部署到tomcat中,启动tomcat;
2、访问:http://xxx/nexus-1.1.1/index.html;
3、用admin/admin123登录;
4、修改admin的密码,但是不要修改别的属性和修改别的用户信息
5、进入administration中的repositories,依次修改三个type是proxy的项目,将其Download Remote Indexes修改为true;然后邮件他们,分别re-index一下;Nexus中有三个重要的代理仓库,分别是中央仓库,Apache仓库,Codehau仓库,他们的每一个仓库都包含了数千或者数万的构件,不可能下载所有构件,而是保存了一个索引,以提供快速和有效的搜索。
6、将你自己机器上的manven缓存(一般是在C:\Documents and Settings\登录名\.m2下面)全部拷贝到/home/你的用户名/sonatype-work/nexus/storage下面的central和releases各一份;
7、修改你本地的(一般是在C:\Documents and Settings\登录名\.m2下面)setting.xml文件改成下面的:

Xml代码 

1. <settings>  

2.       <proxies>  

3.         <proxy>  

4.           <id>normal</id>  

5.           <active>true</active>  

6.           <protocol>http</protocol>  

7.           <username>deployment</username>  

8.           <password>deploy</password>  

9.           <host>172.19.0.177:8080/nexus-1.1.1</host>  

10.           <port>80</port>  

11.           <nonProxyHosts>172.19.0.177:8080/nexus-1.1.1</nonProxyHosts>  

12.         </proxy>  

13.       </proxies>  

14.       <servers>  

15.       </servers>  

16.       <mirrors>  

17.          <mirror>  

18.           <id>nexus-public-snapshots</id>  

19.           <mirrorOf>public-snapshots</mirrorOf>  

20.           <url>http://172.19.0.177:8080/nexus-1.1.1/content/groups/public-snapshots</url>  

21.         </mirror>  

22.         <mirror>  

23.           <!--This sends everything else to /public -->  

24.           <id>nexus</id>  

25.           <mirrorOf>*</mirrorOf>  

26.           <url>http://172.19.0.177:8080/nexus-1.1.1/content/groups/public</url>  

27.         </mirror>  

28.       </mirrors>  

29.       <profiles>  

30.         <profile>  

31.           <id>development</id>  

32.           <repositories>  

33.             <repository>  

34.               <id>central</id>  

35.               <url>http://central</url>  

36.               <releases><enabled>true</enabled></releases>  

37.               <snapshots><enabled>true</enabled></snapshots>  

38.             </repository>  

39.           </repositories>  

40.          <pluginRepositories>  

41.             <pluginRepository>  

42.               <id>central</id>  

43.               <url>http://central</url>  

44.               <releases><enabled>true</enabled></releases>  

45.               <snapshots><enabled>true</enabled></snapshots>  

46.             </pluginRepository>  

47.           </pluginRepositories>  

48.         </profile>  

49.         <profile>  

50.           <id>public-snapshots</id>  

51.           <repositories>  

52.             <repository>  

53.               <id>public-snapshots</id>  

54.               <url>http://public-snapshots</url>  

55.               <releases><enabled>false</enabled></releases>  

56.               <snapshots><enabled>true</enabled></snapshots>  

57.             </repository>  

58.           </repositories>  

59.          <pluginRepositories>  

60.             <pluginRepository>  

61.               <id>public-snapshots</id>  

62.               <url>http://public-snapshots</url>  

63.               <releases><enabled>false</enabled></releases>  

64.               <snapshots><enabled>true</enabled></snapshots>  

65.             </pluginRepository>  

66.           </pluginRepositories>  

67.         </profile>  

68.       </profiles>  

69.         <activeProfiles>  

70.         <activeProfile>development</activeProfile>  

71.       </activeProfiles>  

72. </settings>  

<settings>

      <proxies>

        <proxy>

          <id>normal</id>

          <active>true</active>

          <protocol>http</protocol>

          <username>deployment</username>

          <password>deploy</password>

          <host>172.19.0.177:8080/nexus-1.1.1</host>

          <port>80</port>

          <nonProxyHosts>172.19.0.177:8080/nexus-1.1.1</nonProxyHosts>

        </proxy>

      </proxies>

      <servers>

      </servers>

      <mirrors>

         <mirror>

          <id>nexus-public-snapshots</id>

          <mirrorOf>public-snapshots</mirrorOf>

          <url>http://172.19.0.177:8080/nexus-1.1.1/content/groups/public-snapshots</url>

        </mirror>

        <mirror>

          <!--This sends everything else to /public -->

          <id>nexus</id>

          <mirrorOf>*</mirrorOf>

          <url>http://172.19.0.177:8080/nexus-1.1.1/content/groups/public</url>

        </mirror>

      </mirrors>

      <profiles>

        <profile>

          <id>development</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>

        <profile>

          <id>public-snapshots</id>

          <repositories>

            <repository>

              <id>public-snapshots</id>

              <url>http://public-snapshots</url>

              <releases><enabled>false</enabled></releases>

              <snapshots><enabled>true</enabled></snapshots>

            </repository>

          </repositories>

         <pluginRepositories>

            <pluginRepository>

              <id>public-snapshots</id>

              <url>http://public-snapshots</url>

              <releases><enabled>false</enabled></releases>

              <snapshots><enabled>true</enabled></snapshots>

            </pluginRepository>

          </pluginRepositories>

        </profile>

      </profiles>

        <activeProfiles>

        <activeProfile>development</activeProfile>

      </activeProfiles>

</settings>

  

    将172.19.0.177地址修改为你自己的服务器地址
    
8、在你的项目中的pom.xml中增加一段:

Xml代码 

1. <distributionManagement>  

2.         <repository>  

3.             <id>repo</id>  

4.             <name>public</name>  

5.             <url>http://172.19.0.177:8080/nexus-1.1.1/content/repositories/releases</url>  

6.         </repository>  

7.         <snapshotRepository>  

8.             <id>Snapshots</id>  

9.             <name>Snapshots</name>  

10.             <url>http://172.19.0.177:8080/nexus-1.1.1/content/repositories/snapshots</url>  

11.         </snapshotRepository>  

12.     </distributionManagement>  


这样一来经过我的测试,如果你在没有局域网的环境中(也就是没办法访问你的私服),只要将pom里面的那段删除就可以了。

(这里默认是部署到realease下,我们可以部署到不同的部署仓库,特别是不同的部门之间

有时候会出现401错误,那是因为默认是使用deployment账号登录,realease它的默认的Deployment Policy是“Disable Redeploy”,所以无法部署的问题在这个地方,该过来:

不过这样就变得谁都可以部署了,所以还需要设置deployment的密码:

然后再setting中加上密码:

 <server>

      <id>nexus-releases</id>

      <username>deployment</username>

      <password>deploydv89</password>

    </server>

  

    <server>

      <id>nexus-snapshots</id>

      <username>deployment</username>

      <password>deploydv89</password>

   </server>

注意,pom中的id要和这里的id一致。(这里的密码还可以用其他方法加密)

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多