SpringDemo(XX)--构建SpringBoot项目时,遇到的问题及解决方案

一、项目依赖问题

问题-1.1:@SpringBootApplication注解报红。运行主方法时,提示:“java: 找不到符号:类 SpringBootApplication”

在这里插入图片描述
原因分析: 依赖的jar包中,没有SpringBootApplication类
解决方案:在pom.xml文件中,增加以下配置:

     <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

问题-1.2:package 或 install 项目时,报以下错误信息:

[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.2.RELEASE:repackage (repackage) on project user-api: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.3.2.RELEASE:repackage failed: Unable to find main class -> [Help 1]

原因分析:当前项目依赖了"spring-boot-maven-plugin"模块。当项目依赖"spring-boot-maven-plugin"模块时,项目中必须配置SpringBoot启动类以及主方法;否则就会报以上错误。
在这里插入图片描述

解决方案
(1)如果是工具类等公共模块的项目,可以取消对"spring-boot-maven-plugin"模块的依赖。
(2)如果必须依赖"spring-boot-maven-plugin"模块,则在项目中通过@SpringBootApplication注解 创建启动类以及主方法。

问题-1.3

原因分析
解决方案

问题-1.4

原因分析
解决方案

问题-1.5

原因分析
解决方案

  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值