我有VueJS单页面应用程序,我想转移到Spring Boot项目并在生产环境中运行它。使用npm run build
我生成了这些文件:
Hash: 0e5605ab6a3adbae5bc3
Version: webpack 3.10.0
Time: 34203ms
Asset Size Chunks Chunk Names
static/js/app.a8c2e3befee9add63a47.js 67.9 kB 1 [emitted] app
static/img/bg3.7e9308f.jpg 191 kB [emitted]
static/img/glyphicons-halflings-regular.8988968.svg 109 kB [emitted]
static/fonts/glyphicons-halflings-regular.448c34a.woff2 18 kB [emitted]
static/fonts/glyphicons-halflings-regular.f4769f9.eot 20.1 kB [emitted]
static/fonts/glyphicons-halflings-regular.e18bbf6.ttf 45.4 kB [emitted]
static/fonts/element-icons.6f0a763.ttf 11 kB [emitted]
static/js/vendor.b870d414939280bd7c3a.js 1.1 MB 0 [emitted] [big] vendor
static/fonts/glyphicons-halflings-regular.fa27723.woff 23.4 kB [emitted]
static/js/manifest.58a976c7eeb4e639b033.js 1.49 kB 2 [emitted] manifest
static/css/app.8dfb1913ee552ff55ff81ea142c3f782.css 443 kB 1 [emitted] [big] app
static/css/app.8dfb1913ee552ff55ff81ea142c3f782.css.map 623 kB [emitted]
static/js/vendor.b870d414939280bd7c3a.js.map 3.99 MB 0 [emitted] vendor
static/js/app.a8c2e3befee9add63a47.js.map 267 kB 1 [emitted] app
static/js/manifest.58a976c7eeb4e639b033.js.map 7.8 kB 2 [emitted] manifest
index.html 704 bytes [emitted]
Build complete.
我将它们复制到/resources/static
文件夹。当我运行Spring Boot项目时,我能够打开index.html
文件,但所有相关资源(如js,css和img文件)都会返回404 Not Found Exception
。我甚至无法在浏览器中使用直接链接加载它们。
这很奇怪,因为当我复制并粘贴例如static/css/app.8dfb1913ee552ff55ff81ea142c3f782.css
文件并且只更改名称中的一个数字时,我可以使用浏览器加载它。
这怎么可能?
答案 0 :(得分:0)
看起来资源文件夹中的复制文件在Spring Boot中非常脆弱。通过这些确切的步骤,我能够运行我的项目:
/resources/static
文件夹