gpt4 book ai didi

java - 如何告诉 Spring Boot 将哪个主类用于可执行 jar?

转载 作者:太空宇宙 更新时间:2023-11-04 10:48:15 24 4
gpt4 key购买 nike

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 插件应该使用哪个类作为主类?

最佳答案

在 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>

关于java - 如何告诉 Spring Boot 将哪个主类用于可执行 jar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48142172/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com