Linux installation Nexus3 build maven private server super detailed build upload steps

        Download nexus3.x

Upload the nexus compressed package and decompress it

start up

open port number

browser access

​edit

Set up autostart 

The running user is root (edit nexus.rc under nexus bin)

 Modify the jdk version to be used when nexus3 starts

Modify the default port of nexus3 

 Create a new custom warehouse for private servers

Add roles and users 

add role

Add user

Use Maven private server 

Modify the server configuration file

Modify the local maven configuration file

Modify the POM file in idea


Nexus is a powerful Maven warehouse manager, which greatly simplifies the maintenance of its own internal warehouse and access to external warehouses, which is what we often call private servers

Download nexus3.x

The official download is extremely slow, here is a network disk download:

Link: https://pan.baidu.com/s/1l82aQLPE4V745tXF8ezUxw 
Extraction code: 6lzf

Upload the nexus compressed package and decompress it

cd /data
tar -zxvf nexus-3.25.1-04-unix.tar.gz

start up

cd nexus-3.25.1-04//bin/
ls
./nexus run &
[root@localhost nexus]# cd nexus-3.25.1-04//bin/
[root@localhost bin]# ls
contrib  nexus  nexus.rc  nexus.vmoptions
[root@localhost bin]# ./nexus run &
[1] 106495
[root@localhost bin]# WARNING: ************************************************************
WARNING: Detected execution as "root" user.  This is NOT recommended!
WARNING: ************************************************************

It takes a few minutes for the startup to succeed

open port number

[root@localhost bin]# firewall-cmd --zone=public --add-port=8081/tcp --permanent
success
[root@localhost bin]# firewall-cmd --reload
success

browser access

Default port 8081

 login account

 The default account is admin

view password

find -name admin.password
./sonatype-work/nexus3/admin.password

cat ./sonatype-work/nexus3/admin.password
a3dffe94-17b2-4aea-bcc3-95d1ba126442

 After login, there will be reset password input password

Set up autostart 

create service

vim /usr/lib/systemd/system/nexus.service

 Press i to copy the following into

[Unit] 
Description=nexus service

[Service] 
Type=forking LimitNOFILE=65536 #警告处理
ExecStart=/data/nexus-3.25.1-04/bin/nexus start
ExecReload=/data/nexus-3.25.1-04/bin/nexus restart
ExecStop=/data/nexus-3.25.1-04/bin/nexus stop
Restart=on-failure

[Install]
WantedBy=multi-user.target

Add the service to boot

systemctl enable nexus.service

reload configuration file

systemctl daemon-reload

The running user is root (edit nexus.rc under nexus bin)

cd nexus-3.25.1-04/bin/
vim nexus.rc

 Modify the jdk version to be used when nexus3 starts

cd nexus-3.25.1-04/bin/
vim nexus

Press i to add the following

INSTALL4J_JAVA_HOME_OVERRIDE=/root/java/jdk-11.0.15.1

Modify the default port of nexus3 

The file is in /data/nexus-3.25.1-04/etc/nexus-default.properties

[root@localhost nexus]# vim nexus-3.25.1-04/etc/nexus-default.properties

 Create a new custom warehouse for private servers

Click Create repository, and select the type as maven2(hosted)

 

Enter the warehouse name private-release (custom), and select Release in the Version policy column, indicating that the storage dependency of this warehouse is an officially released component, and then select Allow redeploy in the Deployment policy column to allow deployment and update on private servers s component.
After clicking Create repository, you can see the custom warehouse in the warehouse list, and we will add a snapshot warehouse in the same way, just adjust it to Snapshot in the Version policy column.  Creation of a snapshot repository 

Add roles and users 

add role

Add user

Click Create local user, fill in the user name, password and other required information, and associate with the role we created earlier, click Create local user to save, and the creation is successful.

 

Use Maven private server 

Modify the server configuration file

On the server, open /data/nexus-3.25.1-04/system/setting.xml (vim setting.xml)

cd nexus-3.25.1-04/system
vim settings.xml

Adding true here can upload the version with SHAPSHOT, that is to say, it can be uploaded to the snapshot type library. If not added, the SHAPSHOT suffix can only be removed in the idea, otherwise an error will be reported. 

<settings>
  <servers>
                <server>
                        <id>buba-release</id>
                        <username>qlx</username>
                        <password>123456</password>
                </server>
                <server>
                        <id>buba-snapshot</id>
                        <username>qlx</username>
                        <password>123456</password>
                </server>
  </servers>

  <profiles>
        <profile>
                <id>development</id>
                <repositories>
                        <repository>
                                <id>buba-release</id>
                                <url>http://192.168.216.135:8081/repository/buba-release/</url>
                                <releases><enabled>true</enabled></releases>
                                <snapshots>false</snapshots>
                        </repository>
                        <repository>
                                <id>buba-snapshot</id>
                                <url>http://192.168.216.135:8081/repository/buba-snapshot/</url>
                                <releases><enabled>false</enabled></releases>
                                <snapshots><enabled>true</enabled></snapshots>
                        </repository>
                </repositories>
        </profile>
  </profiles>

  <activeProfiles>
          <activeProfile>development</activeProfile>
  </activeProfiles>
</settings>

Modify the local maven configuration file

Under the label in the local maven configuration file, add the account password and ID configuration for connecting to the private server as follows

<server>
        <id>buba-release</id>
        <username>yjt</username>
        <password>123456</password>
    </server>
    <server>
        <id>buba-snapshot</id>
        <username>yjt</username>
        <password>123456</password>
    </server>

Modify the POM file in idea

Add the following configuration to the POM file in Idea (the url here can be automatically copied through the cpoy button on the warehouse page on the Nexus background)

<distributionManagement>
        <repository>
            <id>buba-release</id>
            <name>buba-release</name>
            <url>http://192.168.216.135:8081/repository/buba-release/</url>
        </repository>

        <snapshotRepository>
            <id>buba-snapshot</id>
            <name>buba-snapshot</name>
            <url>http://192.168.216.135:8081/repository/buba-snapshot/</url>
        </snapshotRepository>
</distributionManagement>

Up to now, we have basically completed the configuration. Execute the deployment command mvn clean deploy or use the deployment plug-in of the IDE to publish. When BUILD SUCCESS appears on the console, it means the release is successful.

At this point, you can view the jar package we released on the warehouse page on the Nexus background 

Guess you like

Origin blog.csdn.net/qq_55629923/article/details/127998676