在IDEA中进行开发时,Maven的插件或依赖显示红线的问题

如果maven的插件显示红线,其实这并不影响运行,但是还是很闹心对吧。

1、可以在maven设置中找到maven库的位置,文件资源管理器打开路径,删除红线的依赖和插件对应的文件/文件夹,再reimport。

2、依赖问题先检查网络,网络没问题的话可以考虑更换依赖的版本,去Maven仓库寻找对应版本号,或者用的最多的版本号(换版本的话,pom也要改),下载更换就可以了。

3、更换阿里云的镜像。在项目-maven-“open settings.xml”或者 “create 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">
    <mirrors>
        <!-- mirror
         | Specifies a repository mirror site to use instead of a given repository. The repository that
         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
         |
        <mirror>
          <id>mirrorId</id>
          <mirrorOf>repositoryId</mirrorOf>
          <name>Human Readable Name for this Mirror.</name>
          <url>http://my.repository.com/repo/path</url>
        </mirror>
         -->

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

        <mirror>
            <id>uk</id>
            <mirrorOf>central</mirrorOf>
            <name>Human Readable Name for this Mirror.</name>
            <url>http://uk.maven.org/maven2/</url>
        </mirror>

        <mirror>
            <id>CN</id>
            <name>OSChina Central</name>
            <url>http://maven.oschina.net/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

        <mirror>
            <id>nexus</id>
            <name>internal nexus repository</name>
            <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
            <url>http://repo.maven.apache.org/maven2</url>
            <mirrorOf>central</mirrorOf>
        </mirror>

    </mirrors>
</settings>

参考https://www.cnblogs.com/tiandi/p/10666454.html

4、还可以下载安装Maven Helper。


版权声明:本文为hhr603894090原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。