MAVEN
IDEA maven配置三要素(本地安装并下载)
-
MAVEN HOME
需要配置好MAVEN的本地环境变量
-
MAVEN settings.xml 配置文件
-
镜像地址——mirros
-
本地仓库位置——localrepositories
如果需要发布到私有仓库,(目前通过nexus)需要配置:
1、server (maven settings.xml)
<servers>
<server>
<id>releases</id>
<username>admin</username>
<password>123456</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>123456</password>
</server>
</servers>
</settings>
2、repository (项目 pom.xml)
<distributionManagement>
<repository>
<id>releases</id>
<name>Nexus Release Repository</name>
<url>http://ip:8081/nexus/repository/maven-releases</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://ip:8081/nexus/repository/maven-snapshots</url>
</snapshotRepository>
</distributionManagement>
plugin (项目 pom.xml)
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<attach>true</attach>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
如果项目有子模块,也需在子模块中配置 plugin
-
MAVEN 本地仓库
从私服中拉取依赖(jar包)
在需要拉取依赖(jar包)的项目的 pom.xml 中添加依赖
<repositories>
<repository>
<id>nexus</id>
<name>Nexus Reposotory</name>
<url>http://192.168.1.113:8081/nexus/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
同时 ,需向 MAVEN 配置(settings.xml)中添加私服的镜像地址,
<id>nexus</id>
<mirrorOf>central</mirrorOf>
<name>Nexus Reposotory</name>
<url>http://192.168.1.113:8081/nexus/repository/maven-public/</url>
</mirror>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)