【问题标题】:Spring boot & React production buildSpring Boot 和 React 生产构建
【发布时间】:2019-03-12 08:01:39
【问题描述】:

我创建了一个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>

【问题讨论】:

    标签: reactjs spring-boot build


    【解决方案1】:

    使用maven copy resources plugin

    【讨论】:

    • 现在,在资源/静态下,我创建了反应项目。然后,我使用“npm run build”创建了构建文件夹。现在当我再次运行项目时,我看到 WhiteLabel 错误。我有使用复制资源插件?
    猜你喜欢
    • 2021-05-03
    • 1970-01-01
    • 1970-01-01
    • 2018-11-08
    • 2020-12-30
    • 2016-05-09
    • 1970-01-01
    • 2021-06-10
    • 1970-01-01
    相关资源
    最近更新 更多