1. 程式人生 > >springboot專案中多個main方法啟動問題

springboot專案中多個main方法啟動問題

SpringBoot專案通過掃描整個專案查詢main方法來啟動整個web。但是當專案中含有不止一個標準main方法時,專案打包成jar包時可能無法正常啟動,找不到要啟動的main;

1 修改pom.xml檔案,用如下方式實現

修改pom.xml檔案,用如下方式實現
<properties>
    <!-- The main class to start by executing java -jar -->
    <start-class>com.microservice.MicroserviceOrderApplication</start-class
>
</properties>

2 在Spring-boot-maven外掛中配置

<properties>
    <!-- The main class to start by executing java -jar -->
    <start-class>com.microservice.MicroserviceOrderApplication</start-class>
</properties>

<build>
    <plugins>
        <plugin
>
<groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <configuration> <mainClass>com.yihaomen.SpringBootWebApplication</mainClass> </configuration>
</plugin> </plugins> </build>