解决Unable to find a single main class from the following candidates

SpringBoot打包异常提示:Unable to find a single main class from the following candidates
说明该项目中有很多main方法,需要制定一个main方法的入口。

在maven项目中加上这个,指定入口和启动类型

 <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <!-- 指定该Main Class为全局的唯一入口 -->
                    <mainClass>com.bsj.boyun.open.car.BoyunOpenCarApplication</mainClass>
                    <layout>ZIP</layout>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>repackage</goal><!--可以把依赖的包都打包到生成的Jar包中-->
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

猜你喜欢

转载自blog.csdn.net/m0_46086429/article/details/106047064