我如何告诉 Spring Boot 哪个主类用于可执行 jar? [英] How do I tell Spring Boot which main class to use for the executable jar?
本文介绍了我如何告诉 Spring Boot 哪个主类用于可执行 jar?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Execution default of goal
org.springframework.boot:spring-boot-maven-plugin:1.0.1.RELEASE:repackage
failed:
Unable to find a single main class from the following candidates
我的项目有多个带有 main
方法的类.我如何告诉 Spring Boot Maven 插件它应该使用哪些类作为主类?
My project has more than one class with a main
method. How do I tell the Spring Boot Maven plugin which of the classes it should use as the main class?
推荐答案
在你的 pom 中添加你的起始类:
Add your start class in your pom:
<properties>
<!-- The main class to start by executing java -jar -->
<start-class>com.mycorp.starter.HelloWorldApplication</start-class>
</properties>
或
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>com.mycorp.starter.HelloWorldApplication</mainClass>
</configuration>
</plugin>
</plugins>
</build>
这篇关于我如何告诉 Spring Boot 哪个主类用于可执行 jar?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文