关于spring新建项目pom.xml报红
我们建立新项目的时候难免会遇到这种类似情况
当时我花了好长时间才慢慢弄懂具体怎么做,接下来便是具体排查。
1.maven的安装配置是否有问题
我们找到maven的安装目录去查看。
本人的安装目录在E盘下,找到了mysettings.xml文件,打开之后,查看maven本地仓库目录,使用localRepository标签自定义本地仓库目录。
<localRepository>E:/apache-maven-3.6.0/repository</localRepository>
我们必须按照maven所在位置来严格配置,例如本人就是在E盘配置的目录地址。
接着就是镜像(中央仓库)的配置。
下面给大家推荐几个常用的镜像地址供大家参考:
阿里云的
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/repositories/central/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>aliyunmaven</id>
<mirrorOf>*</mirrorOf>
<name>阿里云公共仓库</name>
<url>https://maven.aliyun.com/repository/public</url>
</mirror>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>https://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
中央仓库
<mirror>
<id>repo1</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name </name>
<url>https://repo1.maven.org/maven2/</url>
</mirror>
<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</id>
<name>internal nexus repository</name>
<url>https://repo.maven.apache.org/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
中央仓库在中国的镜像
<mirror>
<id>maven.net.cn</id>
<name>oneof the central mirrors in china</name>
<url>https://maven.net.cn/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
junit
<mirror>
<id>junit</id>
<name>junit Address/</name>
<url>https://jcenter.bintray.com/</url>
<mirrorOf>central</mirrorOf>
</mirror>
其他
<mirror>
<id>ibiblio</id>
<mirrorOf>central</mirrorOf>
<name>Human Readable Name for this Mirror.</name>
<url>https://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>https://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
<mirror>
<id>google-maven-central</id>
<name>Google Maven Central</name>
<url>https://maven-central.storage.googleapis.com</url>
<mirrorOf>central</mirrorOf>
</mirror>
这些按理来说都可以用 ,但是鉴于网络问题,其他链接下载特别慢,这里强烈建议大家使用阿里云的网址去下载。
最后还要建议的就是,如果我们遇到了下载jar包失败的问题,很有可能是我们在网上拷贝的http协议过时了,这里建议大家全部改成https,例如:
http://repo.maven.apache.org/maven2
如果这里http不改为https,绝对会报错(本人曾遇到过= =),所以一定要改为https!
https://repo.maven.apache.org/maven2
这样就可以了。
idea中maven的配置
我们打开
File > Settings > Build,Execution,Depolyment > Build Tools > Maven
红框框起来的这三处必须要跟上面所说的本地maven地址一致。
maven的clean与install
最后,如果我们以上步骤均没有问题了,那么点击右侧的maven按钮,以本人的项目举例:
我们首先双击clean,然后看控制台是否出现BUILD SUCCESS
然后我们双击install,直到控制台也出现BUILD SUCCESS为止。(该步骤可能会比较慢,请耐心等待。)
好了,这就是所有关于pom.xml报红的解决办法了,希望对你有所帮助
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)