Nexus 初步使用

1.创建公共maven项目,管理所有依赖;继而创建所有开发子项目。

2.配置所有构建均从私服下载,在~/.m2/setting.xml中配置如下:

    # 监控拦截所有请求
    <mirror>
      <id>mynexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>


    <profile>
      <id>mynexus</id>
      <!--Override the repository (and pluginRepository) "central" from the
         Maven Super POM -->
      <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>


    # 激活配置
    <activeProfiles>
      <!--make the profile active all the time -->
      <activeProfile>mynexus</activeProfile>
    </activeProfiles>


    # 设置部署使用用户
    <server>
       <id>releases</id>
       <username>username1</username>
       <password>password1</password>
    </server>


3.部署构建到Nexus,包含Release和Snapshot, 在项目根目录中pom.xml中配置:

    # 配置部署分发器
    <distributionManagement> 
        <repository> 
            <id>releases</id> 
            <name>Internal Releases</name> 
            <url>http://localhost:8081/nexus/content/repositories/releases/</url> 
        </repository> 
        <snapshotRepository> 
            <id>snapshots</id> 
            <name>Internal Snapshots</name> 
            <url>http://localhost:8081/nexus/content/repositories/snapshots/</url> 
        </snapshotRepository> 
    </distributionManagement>

4.运行deploy Goal。

(启动Nexus:./nexus start  默认浏览器访问地址:http://localhost:8081/nexus)


以下时web maven项目自动部署及运行pom配置:

  # 自动部署并运行webapp项目到tomcat
  <build>
    <finalName>webapp</finalName>
    <plugins>
          <plugin>
              <groupId>org.codehaus.cargo</groupId>
              <artifactId>cargo-maven2-plugin</artifactId>
              <version>1.2.3</version>
              <configuration>
                  <container>
                      <containerId>tomcat7x</containerId>
                      <home>/opt/apache-tomcat-7.0.63</home>
                  </container>
                  <configuration>
                      <type>existing</type>
                      <home>/opt/apache-tomcat-7.0.63</home>
                  </configuration>
              </configuration>
              <executions>
                  <execution>
                      <id>cargo-run</id>
                      <phase>install</phase>
                      <goals>
                          <goal>run</goal>
                      </goals>
                  </execution>
              </executions>
          </plugin>
      </plugins>
  </build>

官网

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值