zoukankan      html  css  js  c++  java
  • 国内maven仓库地址 || 某个pom或者jar找不到的解决方法

    解决方法

    建议在maven仓库中新建settings.xml,然后把如下内容粘贴进去即可。也可以找到maven的安装目录中的conf/settings.xml,把如下的mirrors节复制到对应部分。

    <?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">
        <mirrors>
            <mirror>
                <id>alimaven</id>
                <name>aliyun maven</name>
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
            <mirror>
                <id>central</id>
                <name>Maven Repository Switchboard</name>
                <url>http://repo1.maven.org/maven2/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
            <mirror>
                <id>repo2</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://repo2.maven.org/maven2/</url>
            </mirror>
            <mirror>
                <id>ibiblio</id>
                <mirrorOf>central</mirrorOf>
                <name>Human Readable Name for this Mirror.</name>
                <url>http://mirrors.ibiblio.org/pub/mirrors/maven2/</url>
            </mirror>
            <mirror>
                <id>jboss-public-repository-group</id>
                <mirrorOf>central</mirrorOf>
                <name>JBoss Public Repository Group</name>
                <url>http://repository.jboss.org/nexus/content/groups/public</url>
            </mirror>
            <!-- 中央仓库在中国的镜像 -->
            <mirror>
                <id>maven.net.cn</id>
                <name>oneof the central mirrors in china</name>
                <url>http://maven.net.cn/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
        </mirrors>
    </settings>

    备注

    linux中maven仓库默认本地路径:~/.m2/repository

    windows中maven仓库本地路径:在c盘的某个.m2的文件夹下

    可以用如下命令查看

    如果用eclipse或者intelij的maven插件,需要从对应的ide里面的maven设置中找到maven本地仓库的路径。

    引申

    java项目中的pom.xml可以覆盖如上的远程仓库配置。如下实例

    <repositories>
        <repository>
            <!-- Maven 自带的中央仓库使用的Id为central 如果其他的仓库声明也是用该Id
            就会覆盖中央仓库的配置 --> 
          <id>mvnrepository</id>
            <name>mvnrepository</name>
            <url>http://www.mvnrepository.com/</url>
            <layout>default</layout>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
  • 相关阅读:
    java MessageFormat来生成模板字符串
    linux 用户身份切换
    linux 账号管理
    java 模块化
    mysql 存储过程执行while循环 Lost connection to MySQL server during query
    git 加速
    测试目录
    centos 安装gitblit
    centos7 安装mongoDB
    MySQL 批量修改库、表、列的排序规则,处理数据库大小写不敏感问题。
  • 原文地址:https://www.cnblogs.com/haihua85/p/8684170.html
Copyright © 2011-2022 走看看