本文介绍了Maven-maven-war-plugin更改目标目录(非webapp)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用springboot,但是我不希望它在执行maven-war-plugin任务期间复制我的webapp文件夹,因为它包含很多文件,例如bower_components文件夹.我正在使用grunt,所以要在战争中添加另一个文件夹.

I'm using springboot but I don't want it to copy my webapp folder during maven-war-plugin task because it contains a lot of files like bower_components folder. I'm using grunt so I'm adding another folder to my war.

[INFO] --- maven-war-plugin:2.6:war (default-war) @ saturne ---
[INFO] Packaging webapp
[INFO] Assembling webapp [saturne] in [D:\Workspaces\MyProject\trunk\target\saturne-1.0.0]
[INFO] Processing war project
...
[INFO] Copying webapp resources [D:\Workspaces\MyProject\trunk\src\main\webapp]

我尝试了很多类似在<resources>中将其排除或类似的操作

I tried a lot of things like excluding it in <resources> or like

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.6</version>
    <configuration>
        <webResources>
            <resource>
                <directory>src/main/webapp</directory>
                <exclude>**/*</exclude>
            </resource>
        </webResources>
    </configuration>
</plugin>

我找不到从资源副本中排除它的方法.

I can't find a way to exclude it from resource copy.

推荐答案

这不是SpringBoot的错,maven-war-plugins总是复制webapp文件夹,因此我们通过所需的源更改了它的源.

It's not SpringBoot's fault, maven-war-plugins always copy webapp folder, so we changed it's source by our wanted source.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <warSourceDirectory>${basedir}/src/main/webapp-dist</warSourceDirectory>
     </configuration>
</plugin>

这篇关于Maven-maven-war-plugin更改目标目录(非webapp)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:47