还是那个简单的springboot项目,我只是想将应用打包成一个可执行的jar包,又出现了报错:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:repackage (repackage) on project aaa: Execution repackage of goal org.springframework.boot:spring-boot-maven-plugin:2.3.4.RELEASE:repackage failed: Unable to find main class.
错误原因:
pom.xml中引入了如下配置:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
这里引入了spring-boot-maven-plugin,打包时会去扫描项目main方法入口,也就是说如果要引入该配置,就必须在项目src/main/java/下创建一个spring-boot启动类,且入口类上一定要加上注解 @SpringBootApplication
解决方法:
-
添加spring-boot启动类。
-
将pom.xml中的spring-boot-maven-plugin相关配置注释掉
-
pom.xml中spring-boot-maven-plugin相关配置修改为普通的maven–plugin配置。