spring-boot-maven-plugin 报红解决

 问题描述:

本地编译打包maven项目时,报spring-boot-maven-plugin 构建找不到的错误。昨天还好好的,本地代码里的pom文件没有做任何改动。
pom.xml中有一段下面的配置:(已去掉项目信息)

<!--执行maven命令插件-->
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId> 报红
            </plugin>
        </plugins>
    </build>

关键错误信息如下:
spring-boot-maven-plugin jar包找不到。

分析:

  1. 去本地仓库,检查是否有该jar包
  2. 是否是maven配置的setting.xml文件镜像库路径有问题。
  3. 去远程仓库查看,检查是否有该版本的jar包

 解决:

第一种情况:本地仓库有该jar包,但是在pom.xml文件中报红

通过分析:本地已下载好jar包,只是程序没有刷新找到。

如图点击刷新即可。

或者直接重启idea,再点击。亲测有效。

 第二种情况:本地仓库有该jar包,但是setting.xml文件中maven镜像路径问题

添加镜像路径:

<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>
     -->
	 <!--阿里云镜像1-->
	<mirror>
      <id>aliyunId</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>https://maven.aliyun.com/repository/central</url>
    </mirror>
	 <!--阿里云镜像2-->
	<mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>https://maven.aliyun.com/nexus/content/groups/public/</url>
    </mirror>
	 <!--阿里云镜像3-->
	<mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>https://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>
	 <!--阿里云镜像4-->
	 <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>https://central.maven.org/maven2</url>
    </mirror>
	<!--maven官方镜像-->
	 <mirror>
      <id>mirrorId</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name</name>
      <url>https://repol.maven.org/maven2/</url>
    </mirror>
</mirrors>

第三种情况:本地仓库没有该jar包

spring-boot-maven-plugin没有设置version,它会先去远程仓库找最新的版本,然后download到本地,然后完成maven操作等。但是远程仓库里没有相应的jar包,导致执行maven编译出错。因为远程仓库里已经有了最新版本的路径,它就不会使用已经存在的版本。

解决:

给spring-boot-maven-plugin指定具体的version,如下设置:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.4.3</version>
            </plugin>
        </plugins>
    </build>
  • 17
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
<artifactId>spring-boot-maven-plugin</artifactId>是用于在Maven构建中使用Spring Boot的插件。 您可以在您的pom.xml文件中的plugins部分中指定这个<artifactId>,如下所示: ``` <project> <modelVersion>4.0.0</modelVersion> <artifactId>your-project</artifactId> <!-- ... --> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project> ``` 这样配置后,您可以使用Spring Boot Maven插件来构建和打包您的Spring Boot应用程序。请注意,您还可以在<version>标签中指定特定的版本号,以使用不同的插件版本。 如果您不指定版本号,则默认使用从依赖关系管理中继承的版本。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [springboot maven插件详细说明及使用](https://blog.csdn.net/lijunliang2017/article/details/121362220)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [spring-boot-maven-plugin 报红解决](https://blog.csdn.net/zxf0619/article/details/121363323)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值