Skip to content
<

maven添加镜像与常用配置

maven解压后conf文件夹有个 settings.xml 在这个文件中可以配置我们的maven

配置镜像

找到<mirrors></mirrors>找到这个节点在节点中添加:

xml
<!--  配置阿里云  -->
<mirror>
    <id>nexus-aliyun</id>
    <mirrorOf>*</mirrorOf>
    <name>Nexus aliyun</name>
    <url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>
xml
<!--开源中国镜像仓库-->
<mirror>  
    <id>CN</id>  
    <name>OSChina Central</name>
    <url>http://maven.oschina.net/content/groups/public</url>  
    <mirrorOf>central</mirrorOf><!--表示匹配原仓库的请求都转到镜像仓库-->
</mirror>

配置默认仓库位置

<settings></settings>标签内加入

xml
<localRepository>D:/maven/cangku</localRepository>

配置默认JAVA版本

找到<profiles></profiles>标签在里面添加:

xml
<profile>  
    <id>jdk18</id>  
    <activation>  
        <activeByDefault>true</activeByDefault>  
        <jdk>1.8</jdk>  
    </activation>  
    <properties>  
        <maven.compiler.source>1.8</maven.compiler.source>  
        <maven.compiler.target>1.8</maven.compiler.target>  
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>  
    </properties>   
</profile>