错误404未找到bundle.js - Spring Data Rest和React.js

时间:2018-05-02 18:31:30

标签: javascript spring reactjs spring-boot

我想用Spring构建应用程序并做出反应,所以我开始学习本教程:https://github.com/spring-guides/tut-react-and-spring-data-rest/tree/master/basic

我的项目包含相同的文件 - 我一步一步地完成了所有工作(只是共享了我的项目帮助https://github.com/Lewan110/rest-react)。 Spring Data rest运行良好,因为我获得了正确的数据,但是当我转到http://localhost:8080时,我没有数据和bundle.js的错误

这对我来说很奇怪,因为bundle.js是在:\ src \ main \ resources \ static \ built \ bundle.js中生成的 另外 webpack.config.js 看起来不错:

var path = require('path');

module.exports = {
    entry: './src/main/js/app.js',
    devtool: 'sourcemaps',
    cache: true,
    debug: true,
    output: {
        path: __dirname,
        filename: './src/main/resources/static/built/bundle.js'
    },
    module: {
        loaders: [
            {
                test: path.join(__dirname, '.'),
                exclude: /(node_modules)/,
                loader: 'babel',
                query: {
                    cacheDirectory: true,
                    presets: ['es2015', 'react']
                }
            }
        ]
    }
};

我在React(和JS)中是全新的,我不知道原因在哪里。

1 个答案:

答案 0 :(得分:0)

public文件应位于src文件夹中,而不在bundle.js文件夹中(如果要在开发服务器中使用src,这当然没有意义)

当您为生产使用构建反应应用时,它已准备好直接在您选择的服务器中使用..因此,当您处于开发阶段时,您不会构建您的在你完成工作之前做出反应。

顺便说一下,生成的应用不应该在public文件夹中,它应该位于src和{{1}}个文件夹所在的文件夹中。

相关问题