运行我的jar文件时:java -jar target / places-1.0-SNAPSHOT.jar我遇到下一个错误:
no main manifest attribute, in target/places-1.0-SNAPSHOT.jar
我的pom.xml包含spring-boot-maven-plugin:
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.places.Main</mainClass> </configuration> </plugin>
我也试图创建一个MANIFEST.MF文件并指定该类,但是它没有帮助。
另外,我还尝试了:
<properties> <!-- The main class to start by executing "java -jar" --> <start-class>com.places.Main</start-class> </properties>
我的主要:
@SpringBootApplication public class Main { public static void main(String[] args) throws InterruptedException { SpringApplication.run(Main.class,args); } }
你知道我还能尝试什么吗?
尝试将repackage目标添加到执行目标中。否则,您需要显式调用插件mvn package spring- boot:repackage。添加目标后,您只需致电即可mvn package。
repackage
mvn package spring- boot:repackage
mvn package
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.places.Main</mainClass> </configuration> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin>