IDEA修改settings.xml让maven同时支持本地和远程多仓库
IDEA修改settings.xml让maven同时支持本地和远程多仓库
修改用户目录的settings.xml文件:
C:\Users\maxsh\.m2\settings.xml
首先去掉所有的mirror配置,否则会优先mirror中的仓库。
然后增加profile和activeProfile:
。。。
</profiles>
<profile>
<id>aliyun</id>
<repositories>
<repository>
<id>central</id> <!– 必须使用central名字,否则还会从默认的中央仓库去下载 –>
<name>Aliyun maven mirror.</name>
<url>https://maven.aliyun.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories> <!– 这个是必要的,否则package打包时还是会从默认的url去下载jar文件,不会从aliyun镜像下载 –>
<pluginRepository>
<id>central</id>
<name>Aliyun maven mirror.</name>
<url>https://maven.aliyun.com/repository/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<id>yunbu</id>
<repositories>
<repository>
<id>yunbu-internal-release</id>
<name>Yunbu Internal Release Repository</name>
<url>http://192.168.1.248:8000/repository/maven-releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>yunbu-internal-snapshot</id>
<name>Yunbu Internal Snapshot Repository</name>
<url>http://192.168.1.248:8000/repository/maven-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>aliyun</activeProfile>
<activeProfile>yunbu</activeProfile>
</activeProfiles>
</settings>
如果本地仓库用的是http,不支持https的话,还必须修改maven安装目录下的settings.xml文件:
D:\ideaIU-2022.3.3\plugins\maven\lib\maven3\conf\settings.xml
注释掉这个mirror:
…
<!–
<mirror>
<id>maven-default-http-blocker</id>
<mirrorOf>external:http:*</mirrorOf>
<name>Pseudo repository to mirror external repositories initially using HTTP.</name>
<url>http://0.0.0.0/</url>
<blocked>true</blocked>
</mirror>
–>
…