java -jar XX.jar启动报错:
INFO 2019-07-20 22:00:28 org.springframework.boot.SpringApplication.logStartupProfileInfo(675) | No active profile set, falling back to default profiles: default
ERROR 2019-07-20 22:00:28 org.springframework.boot.SpringApplication.reportFailure(858) | Application run failed
java.lang.IllegalArgumentException: No auto configuration classes found in META-INF/spring.factories. If you are using a custom packaging, make sure that file is correct.
at org.springframework.util.Assert.notEmpty(Assert.java:464)
at org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.getCandidateConfigurations(AutoConfigurationImportSelector.java:183)
解决方法:
pom文件中增加:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
注意:
1 这次是用idea右侧模块的lifecycle->package生产模块下的target的jar是可以启动了
2 生成的jar包反编译看下,里面的MANIFEST.MF是否包含Main-Class
不确定:
META-INFO
->MANIFEST.MF
Manifest-Version: 1.0
Main-Class: com.spider.user.provider.MyUserServiceProviderApplication
文件存放位置是否不要放在src/main/java下面(放在根目录)