仓库
本地仓库
1 2
| <localRepository>/path/to/local/repo</localRepository>
|
Aliyun仓库
第一步:修改 maven 根目录下的 conf 文件夹中的 setting.xml 文件,在 mirrors 节点上,添加内容如下:
1 2 3 4 5 6 7 8
| <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <mirrorOf>central</mirrorOf> </mirror> </mirrors>
|
第二步: pom.xml文件里添加:
1 2 3 4 5 6 7 8 9 10 11 12 13
| <repositories> <repository> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories>
|
仓库安全认证
有些仓库访问是需要安全认证的)等信息不应该在pom.xml文件中配置,这些信息可以配置在settings.xml中.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
| <servers> <server> <id>idea360_server</id> <username>idea360</username> <password>123456</password> </server> </servers>
<profile> <id>dev</id> <repositories> <repository> <id>idea360_server</id> <name>idea360 Repository</name> <url>http://svn.idea360.cn:8082/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository> </repositories> </profile>
<profile> <id>jdk-11</id> <activation> <activeByDefault>true</activeByDefault> <jdk>11</jdk> </activation> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion> </properties> </profile>
|
发布到私服配置
pom.xml
1 2 3 4 5 6 7 8 9 10
| <distributionManagement> <repository> <id>idea360_server</id> <url>http://svn.idea360.cn:8082/repository/maven-releases/</url> </repository> <snapshotRepository> <id>idea360_server</id> <url>http://svn.idea360.cn:8082/repository/maven-snapshots/</url> </snapshotRepository> </distributionManagement>
|
注意:id应该与setting.xml中保持一致
私服浏览
访问 http://svn.idea360.cn:8082/ , 登录后即可看到仓库。
默认仓库说明
- maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
- maven-releases:私库发行版jar,初次安装请将Deployment policy设置为Allow redeploy
- maven-snapshots:私库快照(调试版本)jar
- maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml或项目pom.xml中使用
本地完整配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
| <?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">
<pluginGroups/>
<proxies/>
<servers> <server> <id>idea360_server</id> <username>idea360</username> <password>123456</password> </server> </servers>
<mirrors> <mirror> <id>aliyun-public</id> <mirrorOf>central</mirrorOf> <name>阿里云公共仓库</name> <url>https://maven.aliyun.com/repository/public</url> </mirror> <mirror> <id>aliyun-google</id> <mirrorOf>central</mirrorOf> <name>阿里云谷歌仓库</name> <url>https://maven.aliyun.com/repository/google</url> </mirror> <mirror> <id>aliyun-apache</id> <mirrorOf>central</mirrorOf> <name>阿里云阿帕奇仓库</name> <url>https://maven.aliyun.com/repository/apache-snapshots</url> </mirror> <mirror> <id>aliyun-spring</id> <mirrorOf>central</mirrorOf> <name>阿里云spring仓库</name> <url>https://maven.aliyun.com/repository/spring</url> </mirror> <mirror> <id>aliyun-plugin</id> <mirrorOf>central</mirrorOf> <name>阿里云spring插件仓库</name> <url>https://maven.aliyun.com/repository/spring-plugin</url> </mirror> </mirrors>
<profiles>
<profile> <id>idea360</id> <activation> <activeByDefault>true</activeByDefault> <jdk>11</jdk> </activation> <properties> <maven.compiler.source>11</maven.compiler.source> <maven.compiler.target>11</maven.compiler.target> <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion> </properties> <repositories> <repository> <id>spring</id> <name>aliyun Repository</name> <url>https://maven.aliyun.com/repository/spring</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository>
<repository> <id>idea360_server</id> <name>idea360 Repository</name> <url>http://idea360.cn:8082/repository/maven-public/</url> <releases> <enabled>true</enabled> </releases> <snapshots> <enabled>true</enabled> </snapshots> </repository>
</repositories>
<pluginRepositories> <pluginRepository> <id>central</id> <url>https://maven.aliyun.com/repository/spring-plugin</url> </pluginRepository> </pluginRepositories> </profile> </profiles>
<activeProfiles> <activeProfile>idea360</activeProfile> </activeProfiles>
</settings>
|
最后
本文到此结束,感谢阅读。如果您觉得不错,请关注公众号【当我遇上你】,您的支持是我写作的最大动力。