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/

10-13 09:46