During the development process, some development packages inside the company are sometimes used, and it is obviously inappropriate to put these packages externally. In addition, since the project has been under development, these internal dependencies may also be constantly updated. Third-party and internal dependencies can be managed in a unified manner by building the company's internal Maven server.
Here, Nexus is used to build a local Maven server, and the process is relatively simple.
1. Install the server
1. Download
We can find its related introduction on nexus' official website. The download address is: http://nexus.sonatype.org/downloads/, where you can find the latest version, if you need the previous version , the download address should also be found on the official website. What I downloaded is: nexus-oss-webapp-1.8.0-bundle.tar.gz. For the detailed usage of Nexus, please refer to: Repository Management with Nexus.
2. Install and
decompress the downloaded file:
# tar xzvf nexus-oss-webapp-1.8.0-bundle.tar.gz
After decompression, it will appear in the same level directory. Two folders: nexus-oss-webapp-1.8.0 and sonatype-work, the former contains the nexus runtime environment and applications, the latter contains your own configuration and data.
3. Start nexus
As mentioned above, the operating environment of nexus is in the nexus-oss-webapp-1.8.0 directory, and then enter this directory to start:
# cd nexus-oss-webapp-1.8.0/bin/jsw/linux -x86-64/
This directory contains a folder and three files: lib, nexus, platform and wrapper, where nexus is the startup command.
# ./nexus
Execute the above command, you can get the usage prompt of the nexus command: start command starts, stop command stops. Start nexus as follows:
# ./nexus start
Starting Nexus OSS...
Started Nexus OSS
From the console output, you can see that Nexus has been successfully started. We can view more detailed information through the log file:
# cd ~/nexus-oss-webapp -1.8.0/log
# tail -f wrapper.log
In the log, you can see that the default listening port of nexus is 8081. Then we can access it in the browser: http://host:8081/nexus,
2. Configure Nexus
Since it is just an empty warehouse in the newly built nexus environment, the first step is to communicate with the remote Maven central warehouse to synchronize.
If after Reindex, it is not synchronized to the remote warehouse, you can check the settings of each warehouse. The following are the settings of Maven Central:
3. Use private server in the project
After completing the above configuration, you can switch the default Repository in the project to the local private server, just add repositories in pom.xml:
1.<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2. xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 3. <modelVersion>4.0.0</modelVersion> 4.
5. <groupId>org.maven.demo</groupId> 6. <artifactId>MavenDemo</artifactId> 7. <version>0.0.1-SNAPSHOT</version> 8. <packaging>jar</packaging> 9.
10. <name>MavenDemo</name> 11. <url>http://maven.apache.org</url> 12.
13. <repositories> 14. <repository> 15. <snapshots> 16. <enabled>true</enabled> 17. </snapshots> 18. <id>public</id> 19. <name>Public Repositories</name> 20. <url>http://172.28.189.138:8081/nexus/content/groups/public/</url> 21. </repository> 22. </repositories> 23. <pluginRepositories> 24. <pluginRepository> 25. <id>public</id> 26. <name>Public Repositories</name> 27. <url>http://172.28.189.138:8081/nexus/content/groups/public/</url> 28. </pluginRepository> 29. </pluginRepositories> 30. <dependencies> 31. <dependency> 32. <groupId>junit</groupId> 33. <artifactId>junit</artifactId> 34. <version>4.8.1</version> 35. <type>jar</type> 36. <scope>compile</scope> 37. </dependency> 38. </dependencies> 39. <properties> 40. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 41. </properties> 42.</project> sourceEncoding>UTF-8</project.build.sourceEncoding> 41. </properties> 42.</project> sourceEncoding>UTF-8</project.build.sourceEncoding> 41. </properties> 42.</project>
After saving the pom.xml, look back and look at the nexus management interface, and you will find that junit has been downloaded to the local nexus server.
This article comes from the Linux Commune website (www.linuxidc.com) Original link: http://www.linuxidc.com/Linux/2011-07/39578p3.htm
Use Nexus to build a local Maven server
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=326859011&siteId=291194637
Ranking