1、问题:Unable to find a single main class
命令:spring-boot:run
结果:Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.1.RELEASE:run (default-cli) on project springboot-test: Execution default-cli of goal org.springframework.boot:spring-boot-maven-plugin:1.4.1.RELEASE:run failed: Unable to find a single main class from the following candidates [com.wjc.HelloWorldConfiguration, com.wjc.App] -> [Help 1]
解决:查看提示的两个类,发现均有main方法,去掉一个多余的main方法,保留一个main方法即可。
2、问题:xxx.jar中没有主清单属性
命令:java -jar target/springboot-test-1.0-SNAPSHOT.jar 结果:target/springboot-test-1.0-SNAPSHOT.jar中没有主清单属性
解决:查找资料发现MAVEN插件打包生成的jar包中的META-INF/MANIFEST.MF文件,没有设置主函数信息。配置pom.xml即可;
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>