首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >运行mvn spring-boot:从父模块运行?

运行mvn spring-boot:从父模块运行?
EN

Stack Overflow用户
提问于 2016-12-11 23:14:27
回答 2查看 13.3K关注 0票数 28

我有一个像这样的多模块maven项目:

我的父母

-我的域名

-我的服务

-我的应用程序<<< -这是一个Spring模块

我想直接从父模块运行命令,而不需要cd进入“my”目录first。

我认为这与spring-boot-maven-plugin的配置有关,但我似乎无法正确地理解它。

我尝试了以下几点:

  1. 使用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 module
  2. 不要使用spring-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”属性->帮助1
  3. 不要使用spring-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子模块将按预期的方式启动。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-12 08:25:31

您可以通过在父pom中添加以下内容来做到这一点:

代码语言:javascript
复制
  <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中:

代码语言:javascript
复制
 <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中执行:

代码语言:javascript
复制
mvn -pl my-app -am spring-boot:run

其他参考资料:

票数 48
EN

Stack Overflow用户

发布于 2020-08-06 10:03:53

spring-boot maven插件配置选项:

代码语言:javascript
复制
skip: skips the execution of sprint-boot:run  [default: false]

fork: Flag to indicate if the run processes should be forked [default: true]

请参阅spring-boot maven插件参数

maven选项:

代码语言:javascript
复制
-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选项

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41092200

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档