Based on [five] || maven PW Docker environment to build

Principle 1.Maven Nexus PW

 

To save bandwidth and time, set up a private warehouse server in the LAN, with its agents all external remote repository. When the local Maven when project members need to download, go to PW request, if PW not, go to a remote warehouse request, warehouse downloaded from remote member, the member cache on private servers. In this way, there is no timely temporary Internet link, due to the large number of components, PW has been cached, the entire project can still be used normally. At the same time, also reduces the load on the central warehouse.

 

2. Based on the D Ocker structures M Aven PW

The carrier nexus3 mirror

 

docker pull sonatype/nexus3

 

The inner container / var / nexus-data mount to the host / data / nexus-data directory

 

docker run -d -p 8081:8081 --name nexus -v /data/nexus-data:/var/nexus-data --restart=always sonatype/nexus3

 

Note: maven PW slow start, about 1 minute.

Turn off the firewall , visit HTTP: // ip: 8081  , the default login account admin admin123

 

 3. Create maven PW warehouse

 Click repositories, click Create repository

 

选择maven2(hosted),然后输入仓库名称(test-release)。在version policy中选择这个仓库的类型,这里选择release,在Deployment policy中选择Allow redeploy(这个很重要)

 

 

 4.创建私服账号

创建用户

设置用户名,密码,权限等信息

 

 

 5.本地上次jar包到maven私服

在 maven的settings.xml配置文件中添加私服账号,用户名和密码为maven中分配的私服用户

<servers>
    <server>
        <id>kevin</id>
        <username>kevin</username>
        <password>kevin</password>
      </server>    
 </servers>

创建一个maven工程,并且打包到maven私服,添加以下配置。

<!--注意限定版本一定为RELEASE,因为上传的对应仓库的存储类型为RELEASE -->
    <!--指定仓库地址 -->
    <distributionManagement>
        <repository>
            <!--此名称要和.m2/settings.xml中设置的ID一致 -->
            <id>kevin</id>
            <url>http://192.168.22.7:8081/repository/kevin-release/</url>
        </repository>
    </distributionManagement>

    <build>
        <plugins>
            <!--发布代码Jar插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.7</version>
            </plugin>
            <!--发布源码插件 -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

执行命令:mvn deploy,打包上传到maven私服

6.测试依赖jar包

 

<dependencies>
        <dependency>
            <groupId>com.kevin</groupId>
            <artifactId>kevin-test</artifactId>
            <version>0.0.1-RELEASE</version>
        </dependency>
    </dependencies>

    <repositories>
        <repository>
            <id>kevin</id>
            <url>http://192.168.22.7:8081/repository/kevin-release/</url>
        </repository>
    </repositories>

 

Guess you like

Origin www.cnblogs.com/kevin-ying/p/11198899.html
Recommended