SpringBoot jar包 运行报错:没有主清单属性

原因:由于我没有使用spring-boot-starter-parent,使用的是spring-boot-dependencies

<dependencyManagement>
     <dependencies>
        <dependency>
            
            <groupId>org.springframework.bootgroupId>
            <artifactId>spring-boot-dependenciesartifactId>
            <version>2.3.2.RELEASEversion>
            <type>pomtype>
            <scope>importscope>
        dependency>
    dependencies>
dependencyManagement>

导致spring-boot-maven-plugin的配置项丢失,使得打包后的jar中的MANIFEST.MF文件缺少Main-Class

解决:

法一:(使用spring-boot-dependencies,补全plugin中的配置信息)
<plugin>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-maven-pluginartifactId>
    <version>2.3.2.RELEASEversion>
    <executions>
        <execution>
            <goals>
                <goal>repackagegoal>
            goals>
        execution>
    executions>
plugin>
法二:(使用spring-boot-starter-parent
<parent>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-parentartifactId>
    <version>2.3.2.RELEASEversion>
    <relativePath/> 
parent>
<plugin>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-maven-pluginartifactId>
plugin>

你可能感兴趣的:(Sping,Boot)