从单个 Maven 项目运行多个 SpringBootApplication 类 [英] Running multiple SpringBootApplication classes from a single maven project
本文介绍了从单个 Maven 项目运行多个 SpringBootApplication 类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法指定运行mvn spring-boot:run
时运行哪个SpringBootApplication的主类?文档 说我可以使用 mainClass 参数来指定要运行的主类.但我不确定如何在命令行中指定它.我试过 mvn -DmainClass=mypackage.myclass spring-boot:run
但没有用.
Is there a way to specify which SpringBootApplication's main class to run when running mvn spring-boot:run
? The docs say I can use mainClass parameter to specify which main class to run. But I am not sure how to specify it in command line. I have tried mvn -DmainClass=mypackage.myclass spring-boot:run
but it didn't work.
推荐答案
我通过在 spring-boot 的插件配置中使用占位符使其工作
I got it working by having a placeholder in the plugin configuration of spring-boot
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${mainclass}</mainClass>
</configuration>
</plugin>
然后运行不同的类
mvn -Dmainclass=mypackage.myclass spring-boot:run
这篇关于从单个 Maven 项目运行多个 SpringBootApplication 类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文