reactjs - Spring Boot 和 React 生产构建
问题描述
我创建了一个 Spring Boot 项目。之后,我在 Spring Boot 项目上创建了 React 项目。现在,前端和后端服务器都在运行。在前端文件夹中,我运行该命令npm run build
。
它创建了一个名为 build 的文件夹。我想做的是用一台服务器运行所有项目。(例如:localhost:8080)。我知道我应该将前端文件移动到静态文件夹下。我该怎么做?
我尝试了 maven-antrun-plugin 但它不起作用。
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<configuration>
<target>
<copy todir="${project.build.directory}/classes/public">
<fileset dir="${project.basedir}/frontend/build"/>
</copy>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
解决方案
使用 maven复制资源插件
推荐阅读
- java - Nuxeo 从 8.10 升级到 10.10?
- jquery - VueJS - 使用 jquery $.ajax 发布对象数组
- raspberry-pi - 如何在自助服务终端模式下让 Chromium 自动登录网页?
- java - Maven 传递依赖 - Commons Collection 版本 3 与 4
- swift - 编译确实识别子类 NSWindow 实例
- r - 如何在 R 中实现欧拉方法
- python - 调用函数而不真正调用函数?
- java - 适用于 Cloudera 6.3.2 的 Hbase Spark 连接器
- neo4j - 如何使用 neo4j 创建带有词向量的词汇图?
- c++ - qt QApplication 不显示实时数据