下载 http://120.192.76.70/cache/www.sonatype.org/downloads/nexus-latest-bundle.zip?ich_args=232fba36eda60cc9ee68056f81cb509a_1_0_0_6_4134a24bc046738e6d5d5481bbcd882e530b3f7c84299146b6df2a137e76bacc_67add3538e2edbcfc41f6d5a625eb0d4_1_0&ich_ip=
在centos 上建立用户 nexus
unzip 下载的 安装文件 ,在 运行 nexus start
访问 8081 端口.使用admin admin123 login in ,修改 缺省库地址
修改 m2/setting.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 5 6 <servers> 7 <server> 8 <id>nexus-releases</id> 9 <username>admin</username> 10 <password>admin123</password> 11 </server> 12 <server> 13 <id>nexus-snapshots</id> 14 <username>admin</username> 15 <password>admin123</password> 16 </server> 17 <server> 18 <id>nexus-thirdparty</id> 19 <username>admin</username> 20 <password>admin123</password> 21 </server> 22 </servers> 23 24 <mirrors> 25 <mirror> 26 <id>nexus</id> 27 <mirrorOf>*</mirrorOf> 28 <url>http://48.0.191.154:8081/nexus/content/groups/public</url> 29 </mirror> 30 <mirror> 31 <id>nexus-snapshots</id> 32 <mirrorOf>*</mirrorOf> 33 <url>http://48.0.191.154:8081/nexus/content/groups/public-snapshots</url> 34 </mirror> 35 <mirror> 36 <id>nexus-thirdparty</id> 37 <mirrorOf>*</mirrorOf> 38 <url>http://48.0.191.154:8081/nexus/content/repositories/thirdparty</url> 39 </mirror> 40 <mirror> 41 42 <id>nexus-thirdparty</id> 43 <name>nexus-thirdparty</name> 44 <url>http://48.0.191.154:8081/nexus/content/repositories/thirdparty</url> 45 <mirrorOf>*</mirrorOf> 46 </mirror> 47 </mirrors> 48 <proxies> 49 50 </proxies> 51 <profiles> 52 <profile> 53 <id>nexus</id> 54 <repositories> 55 <repository> 56 <id>nexus</id> 57 <url>http://48.0.191.154:8081/nexus/content/groups/public</url> 58 <releases><enabled>true</enabled></releases> 59 <snapshots><enabled>true</enabled></snapshots> 60 </repository> 61 62 63 <repository> 64 <id>com.springsource.repository.maven.release</id> 65 <url>http://maven.springframework.org/release/</url> 66 <snapshots><enabled>false</enabled></snapshots> 67 </repository> 68 <repository> 69 <id>oracleReleases</id> 70 <name>Oracle Released Java Packages</name> 71 <url>http://download.oracle.com/maven</url> 72 </repository> 73 74 <repository> 75 <id>repo1.maven.org</id> 76 <name>repo1.maven.org</name> 77 <url>http://repo1.maven.org/maven2/</url> 78 </repository> 79 <repository> 80 <id>JBossRepo1</id> 81 <name>Jboss1</name> 82 <url>https://repository.jboss.org/nexus/content/groups/public-jboss/</url> 83 </repository> 84 <repository> 85 <id>JBossRepo</id> 86 <name>Jboss</name> 87 <url>https://repository.jboss.org/nexus/content/repositories/releases/</url> 88 </repository> 89 90 <repository> 91 <snapshots> 92 <enabled>false</enabled> 93 </snapshots> 94 <id>central</id> 95 <name>libs-release-remote</name> 96 <url>http://repo.spring.io/libs-release-remote</url> 97 </repository> 98 <repository> 99 <snapshots /> 100 <id>snapshots</id> 101 <name>libs-snapshot-remote</name> 102 <url>http://repo.spring.io/libs-snapshot-remote</url> 103 </repository> 104 </repositories> 105 <pluginRepositories> 106 107 <pluginRepository> 108 <snapshots> 109 <enabled>false</enabled> 110 </snapshots> 111 <id>central</id> 112 <name>plugins-release</name> 113 <url>http://repo.spring.io/plugins-release</url> 114 </pluginRepository> 115 <pluginRepository> 116 <snapshots /> 117 <id>snapshots</id> 118 <name>plugins-snapshot</name> 119 <url>http://repo.spring.io/plugins-snapshot</url> 120 </pluginRepository> 121 </pluginRepositories> 122 123 </profile> 124 </profiles> 125 <activeProfiles> 126 <activeProfile>nexus</activeProfile> 127 </activeProfiles> 128 </settings> 129 130
如果以前在 .m2 epository中有已经下载的 可以拷贝到 nexus中的库中选择,并 reindex
在项目的 pom.xml
1 <?xml version="1.0" encoding="UTF-8"?> 2 <project xmlns="http://maven.apache.org/POM/4.0.0" 3 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 4 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 5 <modelVersion>4.0.0</modelVersion> 6 7 <groupId>test</groupId> 8 <artifactId>testmaven</artifactId> 9 <version>1.0-SNAPSHOT</version> 10 11 <distributionManagement> 12 <repository> 13 <id>nexus-releases</id> 14 <name>Nexus Release Repository</name> 15 <url>http://48.0.191.154:8081/nexus/content/repositories/releases</url> 16 17 </repository> 18 <snapshotRepository> 19 <id>nexus-snapshots</id> 20 <name>Nexus Snapshot Repository</name> 21 <url>http://localhost:8081/nexus/content/repositories/snapshots</url> 22 23 </snapshotRepository> 24 </distributionManagement> 25 26 <dependencies> 27 28 29 <dependency> 30 <groupId>apache-log4j</groupId> 31 <artifactId>log4j</artifactId> 32 <version>1.2.15</version> 33 </dependency> 34 </dependencies> 35 36 37 </project>