一尘不染

SpringBoot没有主清单属性(Maven)

spring-boot

运行我的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);
  }
  }

你知道我还能尝试什么吗?


阅读 877

收藏
2020-05-30

共1个答案

一尘不染

尝试将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>
2020-05-30