一、项目依赖问题
问题-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:
原因分析:
解决方案: