Maven scattered notes-configure nexus

Source: Internet
Author: User

Install and configure nexus

After decompression, you should obtain the following directory structure:

  • Nexus-2.0.6Is the Home Directory of the nexus service.
  • Sonatype-WorkIs a real repository and also contains nexus configurations, such as scheduled tasks and user configurations.




Nexus supports the following commands:

Reference nexus {console | START | stop | restart | status | dump}



The port is configured inNexus/CONF/nexus. PropertiesFile, the file is as follows:

# Sonatype Nexus# ==============# This is the most basic configuration of Nexus.# Jetty sectionapplication-port=8081application-host=0.0.0.0nexus-webapp=${bundleBasedir}/nexusnexus-webapp-context-path=/nexus# Nexus sectionnexus-work=${bundleBasedir}/../sonatype-work/nexusruntime=${bundleBasedir}/nexus/WEB-INFpr.encryptor.publicKeyPath=/apr/public-key.txt

  

 


If you need to modify the Nexus service port or IP address, you can modify the above section.

After startup, the following interface is displayed:

Default Administrator Account:
Username: Admin
Password: admin123

You can usually find the package in Maven, or you can find it here:


Custom task
Of course, to make your Nexus smarter, you need to perform some scheduled tasks, such as regularly downloading indexes to speed up local MVN retrieval.
For example, to create a regular download indexAdministrationSelectScheduled tasks, ClickAddTo configure:


In addition, I often add some additional jar files to nexus. For example, I want to append the BC package to nexus for other development members of the team.
FindView/Repositories, OpenRepositoriesWindow, select3rd party, Configure as follows:

Then, you can find the jar here:


Private Server Configuration
To allow Maven to access your private server by default, You need to configure settings. xml:

<mirrors>...<mirror><id>nexus</id><mirrorOf>*</mirrorOf><name>Nexus Mirror</name><url>http://<Your Nexus IP>/nexus/content/groups/public</url></mirror>...</mirrors>...<profiles><profile><id>nexus</id><repositories><repository><id>nexus</id><name>local private nexus</name><url><Your Nexus IP>/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></repository><repository><id>nexus</id><name>local private nexus</name><url>http://<Your Nexus IP>/nexus/content/groups/public-snapshots</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></repository></repositories><pluginRepositories><pluginRepository><id>nexus</id><name>local private nexus</name><url>http://<Your Nexus IP>/nexus/content/groups/public</url><releases><enabled>true</enabled></releases><snapshots><enabled>false</enabled></snapshots></pluginRepository><pluginRepository><id>nexus</id><name>local private nexus</name><url>http://<Your Nexus IP>/nexus/content/groups/public-snapshots</url><releases><enabled>false</enabled></releases><snapshots><enabled>true</enabled></snapshots></pluginRepository></pluginRepositories></profile></profiles>...<activeProfiles><activeProfile>nexus</activeProfile></activeProfiles>

  


Deploy jar to nexus

If you use the eclipse Maven tool or directly operate the maven command line, deploy the jar to nexus:
Pom. xml

 
<project>  ...  <distributionManagement>    <repository>      <id>nexus-releases</id>        <name>Nexus Release Repository</name>        <url>http://<Your Nexus IP>/nexus/content/repositories/releases/</url>    </repository>    <snapshotRepository>      <id>nexus-snapshots</id>      <name>Nexus Snapshot Repository</name>      <url>http://<Your Nexus IP>/nexus/content/repositories/snapshots/</url>    </snapshotRepository>  </distributionManagement>  ...  </project>  

  



Settings. xml

<settings>  ...  <servers>    <server>      <id>nexus-releases</id>      <username>admin</username>      <password>admin123</password>    </server>    <server>      <id>nexus-snapshots</id>      <username>admin</username>      <password>admin123</password>    </server>    </servers>  ...  </settings>  

  

Finally, executeMVN deploy

If you want to publish the jar package together with the source package, you need to perform the following Configuration:

 

<plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-source-plugin</artifactId><executions><execution><goals><goal>jar</goal></goals></execution></executions></plugin>

  

Maven scattered notes-configure nexus

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.