SpringBoot没有主清单属性(Maven) [英] SpringBoot no main manifest attribute (maven)

查看:1726
本文介绍了SpringBoot没有主清单属性(Maven)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行我的jar文件时:java -jar target/places-1.0-SNAPSHOT.jar我遇到了下一个错误:

When running my jar file : java -jar target/places-1.0-SNAPSHOT.jar I'm getting the next error :

no main manifest attribute, in target/places-1.0-SNAPSHOT.jar

我的pom.xml包含spring-boot-maven-plugin:

My pom.xml contains the 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 FILE并指定该类,但是它没有帮助.

I also tried to create a MANIFEST.MF FILE and specifying the class but it didnt help.

此外,我也尝试过:

<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);
  }
  }

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

any idea what else can I try ?

推荐答案

尝试将repackage目标添加到执行目标中.否则,您需要将插件显式调用为mvn package spring-boot:repackage.添加目标后,您只需致电mvn package.

Try adding repackage goal to execution goals. Otherwise you would need to call the plugin explicitly as mvn package spring-boot:repackage. With the goal added, you have to call only 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>

这篇关于SpringBoot没有主清单属性(Maven)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆