Nexus 初步使用

来源:互联网 发布:淘宝红号查询 编辑:程序博客网 时间:2024/04/20 08:35

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>

官网

0 0
原创粉丝点击