maven配置文件

查看idea中日志为:Help->Show log in Explorer

maven报错:Return code is: 501 , ReasonPhrase:HTTPS Required

今天把一个去年没做完的项目翻出来做时,发现maven无法正常导入依赖。检查了一遍项目配置,没发现有什么问题。而且依赖在本地仓库存在。

随后发现报错:Failed to transfer file:*********. Return code is: 501 , ReasonPhrase:HTTPS Required. 这时候好像发现了什么重点————我们需要将maven配置修改一下:

<!-- 中央仓库1 -->
        <mirror>
            <id>repo1</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>https://repo1.maven.org/maven2/</url>
        </mirror>

        <!-- 中央仓库2 -->
        <mirror>
            <id>repo2</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>https://repo2.maven.org/maven2/</url>
        </mirror>

一、配置镜像:

配置文件阿里的镜像比较好用:

<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

二、网络代理

代理配置:

 <proxies>
      <proxy>
         <id>my-proxy</id>
         <active>true</active>
         <protocol>http</protocol>
         <host>xxxxx</host>
         <port>8080</port>
          <nonProxyHosts>127.0.0.1|::1|localhost|*.local|10.*|*.hq.cmcc|*.cmri.cn|172.*</nonProxyHosts>  
      </proxy> 
    </proxies>

三、profile构建整个环境的配置,

如配置idea中的jdk7,和jdk8,则在maven中的settings.xml下面添加:

  </profiles>

。。。。。
     <profile>
         <id>jdk-1.7</id>
         <activation>
            <activeByDefault>true</activeByDefault>
             <jdk>1.7</jdk>
          </activation>
         <properties>
             <maven.compiler.source>1.7</maven.compiler.source>
             <maven.compiler.target>1.7</maven.compiler.target>
             <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
         </properties>
    </profile>

    <profile>
        <id>java8-compiler</id>
        <properties>
            <JAVA_HOME>C:\Program Files\Java\jdk1.8.0_91</JAVA_HOME>
            <JAVA_VERSION>1.8</JAVA_VERSION>
        </properties>
        <!-- activeByDefault=true代表如果不指定某个固定id的profile,那么就使用这个环境 -->
    </profile>


  </profiles>

修改后idea中为:

其他说明:

<!--根据环境参数来调整构建配置的列表。settings.xml中的profile元素是pom.xml中profile元素的裁剪版本。它包含了id,activation, repositories, pluginRepositories和 properties元素。这里的profile元素只包含这五个子元素是因为这里只关心构建系统这个整体(这正是settings.xml文件的角色定位),而非单独的项目对象模型设置。如果一个settings中的profile被激活,它的值会覆盖任何其它定义在POM中或者profile.xml中的带有相同id的profile。 -->
    <profiles>
      <!--根据环境参数来调整的构件的配置-->
      <profile>
       <!--该配置的唯一标识符。 -->
       <id>test</id>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值