1.可以为maven项目单独配置nexus路径
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!-- 导入三个 模块 -->
<modules>
<module>../user-core</module>
<module>../user-log</module>
<module>../user-service</module>
</modules>
<groupId>zttc.itat.user</groupId>
<artifactId>user-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!--设定工厂地址,更好的方式是在maven的setting配置文件中设置 这样所有项目都能使用私服的工厂 -->
<repositories>
<repository>
<id>nexus</id>
<name>nexus repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<!--releases默认为true-->
<enabled>true</enabled>
</releases>
<snapshots>
<!--snapshots默认为false-->
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</project>
2.也可以在maven的setting.xml配置全局的路径(常用方式)
<?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
<localRepository>D:\JAVA\MavenRepository</localRepository>
<profiles>
<profile>
<id>nexusProfile</id> <repositories> <repository> <id>nexus</id> <name>nexus repository</name> <url>http://localhost:8081/nexus/content/groups/public/</url> <releases> <!-- releases默认为true --> <enabled>true</enabled> </releases> <snapshots> <!-- snapshots默认为false --> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile> </profiles> <!--激活profile--> <activeProfiles> <activeProfile>nexusProfile</activeProfile> </activeProfiles> </settings>