MAVEN的配置
私服的网址
1. http://localhost:8081/nexus/
maven系统变量的配置
1. MAVEN_HOME
2. C:\Program Files\Maven\apache-maven-3.5.2
1. PATH
2. C:\Program Files\Maven\apache-maven-3.5.2\bin
在项目pom.xml中应该添加
<!--配置私服仓库的地址,本公司的自己的 jar 包会上传到私服的宿主仓库,根据工程的版本号
决定上传到哪个宿主仓库,如果版本为 release 则上传到私服的 release 仓库,如果版本为
snapshot 则上传到私服的 snapshot 仓库,注意:pom.xml 这里<id> 和 settings.xml 配置 <id> 对应!-->
<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
maven的conf文件夹中settings.xml中应该添加
<!--自己设定的本地仓库所在地址-->
<localRepository>C:\Program Files\Maven\maven_repository</localRepository>
<!--电脑上配置 maven环境,并修改 settings.xml
文件,配置连接私服的用户和密码 。
此用户名和密码用于私服校验,因为私服需要知道上传的账号和密码是否和私服中的账号和
密码一致。-->
<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>thirdparty</id>
<username>admin</username>
<password>admin123</password>
</server>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://localhost:8081/nexus/content/groups/public</url>
</mirror>
<!-- 在客户端的 setting.xml 中配置私服的仓库,由于 setting.xml 中没有 repositories 的配置
标签需要使用 profile 定义仓库及默认JDK设置-->
<profile>
<id>jdk-1.8</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
<profile>
<!--profile的id -->
<id>dev</id>
<repositories>
<repository> <!--仓库id,repositories可以配置多个仓库,保证id不重复 -->
<id>nexus</id> <!--仓库地址,即nexus仓库组的地址 -->
<url>http://localhost:8081/nexus/content/groups/public/</url> <!--是否下载releases构件 -->
<releases>
<enabled>true</enabled>
</releases> <!--是否下载snapshots构件 -->
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories> <!-- 插件仓库,maven的运行依赖插件,也需要从私服下载插件 -->
<pluginRepository> <!-- 插件仓库的id不允许重复,如果重复后边配置会覆盖前边 -->
<id>public</id>
<name>Public Repositories</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
</profile>
<!--使用 profile 定义仓库需要激活才可生效-->
<activeProfiles>
<activeProfile>dev</activeProfile>
</activeProfiles>
支持默认MAVEN的配置方法
M2_HOME
C:\Program Files\software\maven\apache-maven-3.5.4
MAVEN_HOME
C:\Program Files\software\maven\apache-maven-3.5.4
CLASSPATH
C:\Program Files\software\maven\apache-maven-3.5.4\lib
PATH
C:\Program Files\software\maven\apache-maven-3.5.4\bin