IDEA创建SpringBoot 2.6.13项目,对生成的代码不做修改直接Maven打包。但运行报错:
[root@centos-7 target]# java -jar system-api-0.0.1-SNAPSHOT.jar
no main manifest attribute, in system-api-0.0.1-SNAPSHOT.jar
解决办法
pom.xml
中注释掉创建时spring-boot-maven-plugin
的<configuration>
的<skip>true</skip>
(忽略配置):
XML
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.sdata.systemapi.SystemApiApplication</mainClass>
<!-- <skip>true</skip>-->
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
重新用maven打包(先clean, 再package),即可