Nexus and Maven installation configuration

1. Download and install Maven
wget http://mirror.bit.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
configure MAVEN_HOME
vi /home /jenkins/.bash_profile
MAVEN_HOME=/usr/local/jenkins/apache-maven-3.5.0
export PATH=$PATH:$MAVEN_HOME/bin
2. Download Nexus
http://www.sonatype.org/nexus/archived/# step2top
wget http://download.sonatype.com/nexus/oss/nexus-2.14.4-03-bundle.tar.gz
tar -zxvf nexus-2.14.4-03-bundle.tar.gz
start: /usr/ local/jenkins/nexus-2.12/bin/nexus start
shutdown: /usr/local/jenkins/nexus-2.12/bin/nexus stop
access: http://192.168.1.135:8081/nexus
default port 8081, default user/password : admin/admin123
3. Configure Nexus
Set the Download Remote Indexes in the Configuration of all projects of type proxy in the list to True



Set the Deployment Policy of the Releases warehouse to Allow ReDeploy



Of course, we can't avoid the use of some third-party jars, and these jar packages do not exist In the maven central repository on the Internet, we can manually add the jar to our private server.
Add a third-party jar as follows:



After filling in the required fields, click the Upload Artifact(s) button.
If you need to delete it, as follows:




4. Use private server configuration
Configure the release jar to your own private server
Modify Maven's configuration file settings.xml
<servers>
    <server>
        <id>releases</id>
        <username>admin</username>
        < password>admin123</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>

Configure the Nexus private server in xml, this configuration is only valid for the current Maven project. <!--Configure the jar package to use the private maven library --> <repositories>


















      <repository>
          <id>public</id>
          <name>Team Maven Repository</name>
          <url>http://172.18.19.157:8081/nexus/content/groups/public/</url>
          <releases>
              <enabled>true</enabled>
          </releases>
          <snapshots>
              <enabled>true</enabled>
          </snapshots>
      </repository>
  </repositories>
<!--配置插件使用私有maven库-->
<pluginRepositories> 
        <pluginRepository> 
            <id>nexus</id> 
            <name>nexus</name> 
            <url>http://172.18.19.157:8081/nexus/content/groups/public/</url> 
            <releases> 
                <enabled>true</enabled> 
            </releases> 
            <snapshots> 
                <enabled>true</enabled> 
            </snapshots> 
        </pluginRepository> 
</pluginRepositories> 
Configure the profile element in Maven's settings.xml so that All Maven projects on this machine can use their own Maven private service.
<profiles>
    <profile>
        <id>dev</id>
        <repositories>
            <repository>
                <id>local-nexus</id>
                <url>http://192.168.1.135:8081/nexus/content/groups/public /</url>
                <

                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
<pluginRepositories>
       <pluginRepository>
         <id>local-nexus</id>
       <url>http://192.168.1.135:8081/nexus/content/groups/public/</url>
         <releases>
         <enabled>true</enabled>
         </releases>
         <snapshots>
               <enabled>true</enabled>
         </snapshots>
       </pluginRepository>
</pluginRepositories>
    </profile>
</profiles>
    <activeProfiles>
        <activeProfile>dev</activeProfile>
</activeProfiles>


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326122590&siteId=291194637