方法一

修改maven的setting文件

插入以下内容

  1. <!-- 公司仓库 -->
  2. <mirror>
  3. <id>detabesnexus</id>
  4. <name>detabesnexus maven</name>
  5. <url>http://127.0.0.1:8081/repository/maven-public/</url>
  6. <mirrorOf>central</mirrorOf>
  7. </mirror>

参考

  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. <localRepository>F:\maven-repository</localRepository>
  6. <pluginGroups>
  7. </pluginGroups>
  8. <proxies>
  9. </proxies>
  10. <servers>
  11. <server>
  12. <id>releases</id>
  13. <username>admin</username>
  14. <password>admin</password>
  15. </server>
  16. <server>
  17. <id>snapshots</id>
  18. <username>admin</username>
  19. <password>admin</password>
  20. </server>
  21. </servers>
  22. <mirrors>
  23. <!-- <mirror>
  24. <id>aliyun</id>
  25. <name>aliyun Maven</name>
  26. <mirrorOf>*</mirrorOf>
  27. <url>http://maven.aliyun.com/nexus/content/groups/public</url>
  28. </mirror> -->
  29. <!-- 私服 -->
  30. <mirror>
  31. <id>detabesnexus</id>
  32. <name>detabesnexus maven</name>
  33. <url>http://192.168.0.3:1100/repository/maven-public/</url>
  34. <mirrorOf>central</mirrorOf>
  35. </mirror>
  36. </mirrors>
  37. <profiles>
  38. <profile>
  39. <id>jdk-1.8</id>
  40. <activation>
  41. <activeByDefault>true</activeByDefault>
  42. <jdk>1.8</jdk>
  43. </activation>
  44. <properties>
  45. <maven.compiler.source>1.8</maven.compiler.source>
  46. <maven.compiler.target>1.8</maven.compiler.target>
  47. <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
  48. </properties>
  49. </profile>
  50. </profiles>
  51. </settings>

方法二

修改项目的pom.xml

插入以下内容

  1. <repositories>
  2. <repository>
  3. <id>local-nexus</id>
  4. <url>http://192.168.0.3:1100/repository/maven-public/</url>
  5. <releases>
  6. <enabled>true</enabled>
  7. </releases>
  8. <snapshots>
  9. <enabled>true</enabled>
  10. </snapshots>
  11. </repository>
  12. </repositories>

参考

  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. <groupId>com.detabes</groupId>
  7. <artifactId>smart-appointment</artifactId>
  8. <packaging>pom</packaging>
  9. <version>1.0.0</version>
  10. <modules>
  11. <!-- 文档网关 -->
  12. <module>swagger</module>
  13. <!-- 业务网关 -->
  14. <module>gateway</module>
  15. <!-- 硬件 -->
  16. <module>hardware</module>
  17. <!-- 业务 -->
  18. <module>modules</module>
  19. <!-- 公共方法 -->
  20. <module>common</module>
  21. <!-- 文件 -->
  22. <module>file</module>
  23. </modules>
  24. <parent>
  25. <groupId>com.detabes</groupId>
  26. <artifactId>detabes-component</artifactId>
  27. <version>1.0.0</version>
  28. </parent>
  29. <repositories>
  30. <repository>
  31. <id>local-nexus</id>
  32. <url>http://192.168.0.3:1100/repository/maven-public/</url>
  33. <releases>
  34. <enabled>true</enabled>
  35. </releases>
  36. <snapshots>
  37. <enabled>true</enabled>
  38. </snapshots>
  39. </repository>
  40. </repositories>
  41. </project>

注意

存在匿名和非匿名的使用方式

  • 匿名
    • 仓库地址能访问到就行了
    • Nexus配置可以匿名访问
      • 项目使用文档 - 图1
  • 非匿名
    • 必须在mavne的 setting中 填上账号密码
      1. <servers>
      2. <server>
      3. <id>releases</id>
      4. <username>admin</username>
      5. <password>nexus@peter</password>
      6. </server>
      7. <server>
      8. <id>snapshots</id>
      9. <username>admin</username>
      10. <password>nexus@peter</password>
      11. </server>
      12. </servers>