添加了 spring-boot-maven-plugin 插件后, 当运行 maven 打包的命令, 项目会被打包成一个可以直接运行的 jar 包, 使用 "java -jar" 可以直接运行.
当项目中有两个启动类时, 需要制定要执行的类, 如果不指定, 启动会报错.
指定启动类有两种情况需要区分
一: pom 文件继承自 spring-boot-starter-parent
- <properties>
- <start-class>com.xx.xx</start-class>
- </properties>
二: pom 文件不是继承自 spring-boot-starter-parent
- <build>
- <plugins>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>2.0.5.RELEASE</version>
- <configuration>
- <mainClass>com.xx.xx</mainClass>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
来源: https://www.cnblogs.com/tinyj/p/9786552.html