解决IDEA springboot“spring-boot-maven-plugin“报红问题方法

本篇文章小编给大家分享一下解决IDEA springboot”spring-boot-maven-plugin”报红问题方法,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看。

使用环境

项目环境:Idea 2020.2.3、 Maven 3.6.3 、springboot 2.1.4

在创建springboot项目时spring-boot-maven-plugin 及Idea右侧Plugins划红,导致项目启动打包有问题。虽然项目能跑,但是后续开发中可能会出现不可预知的问题。太碍眼决定把它解决掉。

可能原因:

1、maven没有刷新;

2、Maven插件下载速度太慢,从国外的中央仓库下载;

3、也有可能是本地springboot版本问题等….

分析思路:

1、到仓库中发现有这插件,然后clean install 以后reimport还是飘红。

2、那我们找到Maven地址中的setting.xml中的mirrors标签添加以下内容,maven再次下载jar包时,idea中看到,从阿里云提供的地址下载,速度比中央仓库快

<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
                      https://maven.apache.org/xsd/settings-1.0.0.xsd">
    <localrepository>C:Usersxxx.m2repository</localrepository> <!--这个地方改成自己本地路径-->
    <interactivemode>
    <offline>
    <plugingroups>
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorof>central</mirrorof>       
        </mirror>
        <mirror> 
            <id>repo1.maven.org</id> 
            <name>Repo1 Maven of https://repo1.maven.org/maven2/</name> 
            <url>https://repo1.maven.org/maven2/</url> 
            <mirrorof>central</mirrorof> 
        </mirror>
        <!--
        -->
    </mirrors>
    <proxies>
    <profiles>
        <profile>
            <id>downloadSources</id>
            <properties>
                <downloadsources>true</downloadsources>
                <downloadjavadocs>true</downloadjavadocs>          
            </properties>
        </profile>
    </profiles>
    <activeprofiles>
      <activeprofile>downloadSources</activeprofile>
    </activeprofiles>
</proxies></plugingroups></offline></interactivemode></settings>
<mirror> 
<id>alimaven</id> 
<name>aliyun maven</name> 
<url>http://maven.aliyun.com/nexus/content/groups/public/</url> 
<mirrorof>central</mirrorof> 
</mirror>

但是以上两个方法依然没有解决,因为项目都是其它同事一直能跑起来过的,那就说明程序肯定没问题。主要我之前也是跑得好好的,也就换了一下系统,Idea版本也安装到2020.2.3 版本而已,到此心里感觉到了崩溃的边缘,只想说这是为什么……

然后实在找不到问题所在 ,最后试着改了改pom.xml文件

<version>2.2.2.RELEASE</version>

 居然和版本有关系,问题就解决了。

我试着修改成

<artifactId>spring-boot-maven-plugin-</artifactId>

后面加个-,然后改回来,就恢复正常了。

文章出处登录后可见!

已经登录?立即刷新

共计人评分,平均

到目前为止还没有投票!成为第一位评论此文章。

(0)
社会演员多的头像社会演员多普通用户
上一篇 2023年12月11日
下一篇 2023年12月11日

相关推荐