Maven是声明式的,Maven约定优于配置。还有Maven重要的中央仓库私服。以下是重要的Maven私服的配置代码,记录下方便以后查看。
在pom文件中配置
<repositories> <repository> <id>nexus</id> <name>mynexus</name> <url>http://192.168.0.153:8081/nexus/content/groups/public/</url> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>mynexus</name> <url>http://192.168.0.153:8081/nexus/content/groups/public/</url> </pluginRepository> </pluginRepositories> <distributionManagement> <repository> <id>nexus-releases</id> <url>http://192.168.0.153:8081/nexus/content/repositories/releases/</url> </repository> <snapshotRepository> <id>nexus-snapshots</id> <url>http://192.168.0.153:8081/nexus/content/repositories/snapshots/</url> </snapshotRepository> </distributionManagement>
在settings文件里的配置
<profile> <id>nexus</id> <repositories> <repository> <id>nexus</id> <name>mynexus</name> <url>http://192.168.0.153:8081/nexus/content/repositories/central/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> <pluginRepositories> <pluginRepository> <id>nexus</id> <name>mynexus</name> <url>http://192.168.0.153:8081/nexus/content/repositories/central/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </pluginRepository> </pluginRepositories> </profile>
在settings文件里的配置
<mirror> <id>nexus</id> <name>mynexus</name> <url>http://192.168.0.153:8081/nexus/content/groups/public/</url> <mirrorOf>*</mirrorOf> </mirror>
其中要注意的是<id></id>pom里的和settings里的要保持一致