运行Jar包出现:xxx中没有主清单属性报错

发布时间 2023-08-21 11:34:31作者: 下课后我要去放牛

1、项目打好jar包时,使用命令运行jar包:

java -jar xxx.jar

出现报错:xxx中没有主清单属性

 

解决办法:亲测有用

在pom.xml配置中,加上以下配置:

<build>
        <!--打包成jar包时的名字-->
        <finalName>xxxTest</finalName>
        <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>

 

 

再打包运行时,成功输出日志