我有一个像这样的多模块maven项目:
我的父母
-我的域名
-我的服务
-我的应用程序<<< -这是一个Spring模块
我想直接从父模块运行命令,而不需要cd进入“my”目录first。
我认为这与spring-boot-maven-plugin的配置有关,但我似乎无法正确地理解它。
我尝试了以下几点:
spring-boot-starter-parent和默认配置spring-boot-maven-plugin,包括在我的应用程序的插件部分。
从父级运行mvn spring-boot:run将得到以下结果:
Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (default-cli) on project my-parent: Unable to find a suitable main class, please add a 'mainClass' property -> [Help 1] in the parent modulespring-boot-starter-parent。
按照所描述的elewhere在spring-boot-dependencies中定义depManagement。
在spring-boot-maven-plugin我的父级的pluginManagement部分中定义,并在my模块的插件部分中包含插件。
运行mvn spring-boot:从父程序运行将导致与#1相同的错误:
未能在项目我的父级项目上执行org.springframework.boot:spring-boot-maven-plugin:1.4.2.RELEASE:run (默认-cli):无法找到合适的主类,请添加“mainClass”属性->帮助1spring-boot-starter-parent。
按照所描述的elewhere在spring-boot-dependencies中定义depManagement。
在my插件部分定义。
运行mvn spring-boot:从父结果运行:
No plugin found for prefix 'spring-boot' in the current project and in the plugin groups在上述所有情况下,从my目录运行mvn spring-boot:run都很好。
我想应该有办法让这件事成功的。在传统的非引导Spring项目中,配置tomcat7插件相当简单,这样我就可以从父程序运行mvn tomcat7:run-war,webapp子模块将按预期的方式启动。
发布于 2016-12-12 08:25:31
您可以通过在父pom中添加以下内容来做到这一点:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>在您的my (Spring模块)pom中:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<fork>true</fork>
<skip>false</skip>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>现在您可以在project中执行:
mvn -pl my-app -am spring-boot:run其他参考资料:
发布于 2020-08-06 10:03:53
spring-boot maven插件配置选项:
skip: skips the execution of sprint-boot:run [default: false]
fork: Flag to indicate if the run processes should be forked [default: true]maven选项:
-pl, --projects: Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path
-am, --also-make: If project list is specified, also build projects required by the list请参阅maven CLI选项
https://stackoverflow.com/questions/41092200
复制相似问题