SpringBoot项目打包为jar后报为找到main方法,ClassNotFound...

SpringBoot项目打包为jar后报为找到main方法,ClassNotFound...

在报错的modules的pom内加上下面的插件即可。

    <build>
       <plugins>
           <!-- 不加这个参数打jar包会报未找到main方法 -->
           <plugin>
               <groupId>org.springframework.boot</groupId>
               <artifactId>spring-boot-maven-plugin</artifactId>
               <version>2.4.1</version>
               <configuration>
                   <includeSystemScope>true</includeSystemScope>
                   <mainClass>cn.vantee.EurekaServerStarter7001</mainClass>
               </configuration>
               <executions>
                   <execution>
                       <goals>
                           <goal>repackage</goal>
                       </goals>
                   </execution>
               </executions>
           </plugin>
       </plugins>
    </build>
原文地址:https://www.cnblogs.com/zhangruifeng/p/15730577.html