spring-boot maven插件重新运行编译&测试阶段

时间:2014-05-22 11:25:05

标签: maven-plugin spring-boot

使用spring-boot-maven-plugin run和repackage目标导致我的编译和测试阶段重新运行,例如。

mvn clean package spring-boot:run

你会看到两个编译和测试运行......

在maven debug out中我可以看到

...
[DEBUG] Goal:          org.springframework.boot:spring-boot-maven-plugin:1.0.2.RELEASE:repackage (default)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <finalName default-value="${project.build.finalName}"/>
  <outputDirectory default-value="${project.build.directory}"/>
  <project default-value="${project}"/>
</configuration>
[DEBUG] --- init fork of myapp:1.0-SNAPSHOT for     org.springframework.boot:spring-boot-maven-plugin:1.0.2.RELEASE:run (default-cli) ---
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [compile, test]
[DEBUG] -----------------------------------------------------------------------

看一下插件源代码类,RunMojo和RepackageMojo我看到了

@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE, requiresDependencyResolution = ResolutionScope.TEST)
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class RunMojo extends AbstractMojo {

认为@Execute与它有关系吗?

由于

2 个答案:

答案 0 :(得分:2)

是。你为什么不用“mvn spring-boot:run”?据我所知,这就是Maven的工作方式。

答案 1 :(得分:0)

我的不好......实际上是cobertura插件这样做是可以理解的,因为它需要重新编译源代码以进行覆盖。