英文:
Changing order of applying maven spring-boot and war plugins
问题
我正在使用 spring-boot-maven-plugin
将 Spring Boot 添加到我的应用程序中,还使用 >maven-war-plugin
将生成的 .war
文件移动到目标(本地文件系统)位置。
不幸的是,当我将它们都添加到 pom.xml
中时:
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<outputDirectory>C:/Location</outputDirectory>
</configuration>
</plugin>
</plugins>
发生的情况是首先生成 .war
文件,然后将其移动到 C:/Location
,随后项目构建中 /target
中原始的 .war
文件被 spring-boot-maven-plugin
更新(可以通过控制台输出和 .war
文件在 /target
内部的更大文件大小来确认)。
因此,最终我得到的是位于错误位置的正确 .war
文件,以及位于正确位置的错误(在添加 Spring Boot 之前的) .war
文件。
是否有一种方法可以使这些步骤以相反的顺序发生?首先应用 Spring Boot,然后将结果移动到 C:/Location
?
我尝试过通过在 spring boot 的 <plugin>
中添加:
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
以及在 war 插件中添加:
<executions>
<execution>
<phase>install</phase>
</execution>
</executions>
但似乎没有任何效果(spring boot 在 war 插件之后被应用):
[INFO] --- maven-war-plugin:3.2.1:war (default-war) @ app ---
[INFO] Packaging webapp
[INFO] Assembling webapp [app] in [G:\app\target\app-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [G:\app\src\main\webapp]
[INFO] Webapp assembled in [310 msecs]
[INFO] Building war: C:\Location\app-0.0.1-SNAPSHOT.war
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.4.RELEASE:repackage (repackage) @ app ---
[INFO] Replacing main artifact with repackaged archive
英文:
I am using spring-boot-maven-plugin
to add spring boot to my application and also >maven-war-plugin
to move the generated .war
to target (local filesystem) destination.
Unfortunatelly, when I add both of them into pom.xml
:
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.1</version>
<configuration>
<outputDirectory>C:/Location</outputDirectory>
</configuration>
</plugin>
</plugins>
What happens is that first the .war
is generated. Than moved to C:/Location
. And later the original .war
in /target
of my project build is getting updated with spring-boot-maven-plugin
(it can be confirmed both by console output and greater file size of .war
inside /target
.
So I end up with correct .war
in inccorect location and incorrect .war
(before adding spring boot) in correct location.
Is there a way to make those steps happen in reverse order? To first apply spring boot and later move the result to C:/Location
?
I've tried by adding:
<executions>
<execution>
<phase>package</phase>
</execution>
</executions>
to <plugin>
for spring boot and:
<executions>
<execution>
<phase>install</phase>
</execution>
</executions>
for war plugin, but it seems to take no effect whatsoever (spring boot is applied after war plugin):
[INFO] --- maven-war-plugin:3.2.1:war (default-war) @ app ---
[INFO] Packaging webapp
[INFO] Assembling webapp [app] in [G:\app\target\app-0.0.1-SNAPSHOT]
[INFO] Processing war project
[INFO] Copying webapp resources [G:\app\src\main\webapp]
[INFO] Webapp assembled in [310 msecs]
[INFO] Building war: C:\Location\app-0.0.1-SNAPSHOT.war
[INFO]
[INFO] --- spring-boot-maven-plugin:2.2.4.RELEASE:repackage (repackage) @ app ---
[INFO] Replacing main artifact with repackaged archive
专注分享java语言的经验与见解,让所有开发者获益!
评论