【发布时间】:2018-02-28 05:27:05
【问题描述】:
我正在使用tomcat7-maven-plugin,我的网络应用程序存储在src/main/webapp。它是一个 React 应用程序,所以我运行 npm run build 以在 src/main/webapp/build 中生成“编译”版本。我的问题是,每当我打包 webapp 时,都会打包整个 webapp 文件夹(包括 node_modules...),而不仅仅是 build 文件夹。
这是我的插件配置:
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<configuration>
<port>9090</port>
<!-- I am looking for something of the following form -->
<webappPath>build</webappPath>
</configuration>
</plugin>
</plugins>
</pluginManagement>
如何让插件只打包webapp/build 目录?或者也许有办法至少从包中排除 node_modules,因为所有这些模块都只用于创建我的 webapp 的打包版本?
【问题讨论】:
-
我猜 tomcat7-maven-plugin 只是用于最终部署,作为更大战争项目 (
war ) 的一部分?要在将生成的 war 文件发送到 Tomcat 之前对其进行优化,您还需要为 maven-war-plugin 添加一些配置 - 沿 these 行。 -
您好,我认为您正在尝试做一些不正确的事情。我建议将您的代码移动到其他文件夹,例如 src/main/js(查看 frontend-maven-plugin)更改 war 构建过程以在 war 组装期间将构建目录添加到 war 文件。一些指导已经存在,看看这个stackoverflow.com/questions/36590900/…
标签: java maven tomcat7-maven-plugin