zoukankan      html  css  js  c++  java
  • maven无法自动下载依赖包settings.xml文件配置

    问题:springboot项目中,在pom.xml配置了依赖引用不会自动下载

    需要设置maven的settings.xml文件

    查看对应目录是否存在settings.xml文件

    如果没有则需要添加文件settings.xml到该目录,文件内容如下:

    <?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">
    
        <!-- 本地仓库的位置 -->
        <localRepository>${user.home}/.m2/repository</localRepository>
      
        <!-- Apache Maven 配置 -->
        <pluginGroups/>
        <proxies/>
    
        <!-- 私服发布的用户名密码 -->
        <servers>
            <server>
                <id>releases</id>
                <username>deployment</username>
                <password>He2019</password>
            </server>
            <server>
                <id>snapshots</id>
                <username>deployment</username>
                <password>He2019</password>
            </server>
        </servers>
        
        <!-- 阿里云镜像 -->
        <mirrors>
            <mirror>
                <id>alimaven</id>
                <name>aliyun maven</name>
                <!-- https://maven.aliyun.com/repository/public/ -->
                <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                <mirrorOf>central</mirrorOf>
            </mirror>
        </mirrors>
    
        <!-- 配置: java8, 先从阿里云下载, 没有再去私服下载  -->
        <!-- 20190929 hepengju 测试结果: 影响下载顺序的是profiles标签的配置顺序(后面配置的ali仓库先下载), 而不是activeProfiles的顺序 -->
        <profiles>
            <!-- 全局JDK1.8配置 -->
            <profile>
                <id>jdk1.8</id>
                <activation>
                    <activeByDefault>true</activeByDefault>
                    <jdk>1.8</jdk>
                </activation>
                <properties>
                    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
                    <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>
    
            
            <!-- Nexus私服配置: 第三方jar包下载, 比如oracle的jdbc驱动等 -->
            <profile>
                <id>dev</id>
                <repositories>
                    <repository>
                        <id>nexus</id>
                        <url>http://nexus.hepengju.cn:8081/nexus/content/groups/public/</url>
                        <releases>
                            <enabled>true</enabled>
                        </releases>
                        <snapshots>
                            <enabled>true</enabled>
                        </snapshots>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>public</id>
                        <name>Public Repositories</name>
                        <url>http://nexus.hepengju.cn:8081/nexus/content/groups/public/</url>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
            
            <!-- 阿里云配置: 提高国内的jar包下载速度 -->
            <profile>
                <id>ali</id>
                <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>true</enabled>
                        </snapshots>
                    </repository>
                </repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>alimaven</id>
                        <name>aliyun maven</name>
                        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
                    </pluginRepository>
                </pluginRepositories>
            </profile>
    
        </profiles>
        
        <!-- 激活配置 --> 
        <activeProfiles>
            <activeProfile>jdk1.8</activeProfile>
            <activeProfile>dev</activeProfile>
            <activeProfile>ali</activeProfile>
        </activeProfiles>
    </settings>

           maven的settings文件说明:  https://yq.aliyun.com/articles/625836?spm=a2c4e.11153940.0.0.b2133f1avcLO9w

      maven的pom文件的说明:https://yq.aliyun.com/articles/626435?spm=a2c4e.11155435.0.0.1cf4a46c25Bwgd

     添加完之后刷新maven即可重新下载

  • 相关阅读:
    LeetCode 【1】 Two Sum --001
    计算机网络-自定向下方法之应用层
    Android TextView自动换行、排列错乱问题及解决
    Android ScrollView内部组件设置android:layout_height="fill_parent"无效的解决办法
    Gson解析空字符串异常的处理
    AndroBench手机性能测试
    使用adb命令通过IP地址连接手机
    Android string.xml 添加特殊字符
    Android string资源 包含 数学符号等特殊字符 及 参数占位符
    Android Studio多渠道打包(二)
  • 原文地址:https://www.cnblogs.com/duanzq/p/13091952.html
Copyright © 2011-2022 走看看