<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<!--exec-maven-plugin插件可以执行cmd命令-->
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>exec-npm-run-build</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!--程序名称-->
<executable>npm</executable>
<arguments>
<!-- 程序所执行的命令-->
<argument>run</argument>
<argument>build</argument>
</arguments>
<!--${basedir}项目根目录-->
<!--前端代码地址-->
<workingDirectory>${basedir}\web</workingDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--maven-resources-plugin:maven复制文件插件-->
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resource</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<!--输出文件路径-->
<outputDirectory>${basedir}\src\main\resource\template</outputDirectory>
<resources>
<resource>
<!--前端代码地址-->
<directory>${basedir}\web</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
maven执行命令:mvn clean package
参考: https://blog.csdn.net/randompeople/article/details/82629922
参考: https://www.cnblogs.com/xzf-forever/p/6842984.html?utm_source=itdadao&utm_medium=referral