简述
项目开发中,很多情况下我们会打成jar启动,此时如果jar中出现多个含有main的类,启动一般会报错,此时可以通过在pom中指定启动类来解决这个问题。
第一种:
如果你的POM是继承spring-boot-starter-parent的话,只需要在pom的root如下指定就行
<properties>
<!-- 指定启动类 -->
<start-class>com.besttop.BaseServerApplication</start-class>
</properties>
第二种:
如果你的Pom中没有继承Spring-boot-start-parent,那么需要通过如下配置实现。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>1.3.5.RELEASE</version>
<configuration>
<!-- 指定启动类 -->
<mainClass>com.xx.xx</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>