查看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>