Docker in the build Maven PW

Why use Maven PW?

In the actual development, the project might be used in third-party jar, internal communication service interface will be driven into the company in the PW.

From a practical point of view of our development projects:

  1. Some can not be downloaded from an external warehouse components, such as internal project also deployed to PW, in order to rely on for other projects.

  2. 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 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. It also reduces in line with the central warehouse.

PW excerpt from the server set as described above, the following detailed steps:

1, download the image of a nexus3

docker pull sonatype/nexus3

2, the inner container / var / nexus-data to the host to mount / root / nexus-data directory

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

-a view of the container case started by docker ps

Authentication, detail information container by id, ip address as output.

docker inspect 容器id

Then go to the following address Try this: curl 127.17.0.2:8081

If the boot fails, you can turn off the firewall try again:

systemctl stop firewalld.service

ok, after the launch a browser to look at http: // ip: 8081

So far, PW build success.

The default login account admin admin123

Note that this time you may encounter this error as follows:

Incorrect username or password, or no permission to use the application.

The default login time maven PW can not use clear text passwords, use cipher text, usually in the directory you create a container, such as root / Nexus-the Data / admin.password , attention to the need to find into the container, and instructions see below Figure:

docker exec -it c2101070de57 bash
bash-4.2$ cd /nexus-data/
bash-4.2$ cat admin.password 
d62fa667-a22b-41db-a14a-6aa6f793f4fbbash-4.2

Removing behind the bash-4.2 $ , d62fa667-A22 b-41dB-A14a-6aa6f793f4fb is the password.

After re-visit, you will be prompted to reset your password:

3, create a maven repository

上传maven私服之前我们先,创建个仓库

选择maven2(hosted)

填写仓库信息:

创建用户:

填写基本信息

创建好账户后就可以在右上角切换账户了。

接着就是配置本地 maven > conf 了,找到自己本机的 maven conf 下的 setting.xml 文件,添加如下信息:

注意是 services 节点下:

<services>
    <server>
        <id>ttyy</id>
        <username>ttyy</username>
        <password>ttyy</password>
    </server>
 </services>

4、如何将架包上传到maven私服

创建一个普通的 maven 项目,配置 pom.xml 如下:

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

发布成功后,如何搜索呢?如下图:

发布后如何使用呢,相信很多小伙伴肯定用过阿里云的私服,一样的道理啦:

<dependencies>
    <dependency>
        <groupId>club.sscai</groupId>
        <artifactId>ttyy-springboot</artifactId>
        <version>1.0-RELEASE</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>ttyy</id>
        <url>http://192.168.10.130:8081/repository/ttyy-release/</url>
    </repository>
</repositories>

我创建了一个java相关的公众号,用来记录自己的学习之路,感兴趣的小伙伴可以关注一下微信公众号哈:niceyoo

Guess you like

Origin www.cnblogs.com/niceyoo/p/11204143.html