1. 注意看下vue项目config目录中Index.js文件,看是否是以下配置:
build: {
sitEnv:
require(
'./sit.env'),
prodEnv:
require(
'./prod.env'),
index:
path.
resolve(
__dirname,
'../dist/index.html'),
assetsRoot:
path.
resolve(
__dirname,
'../dist'),
assetsSubDirectory:
'static',
assetsPublicPath:
'./',
//请根据自己路径配置更改
staticPath:
'./static/',
//请根据自己路径配置更改
productionSourceMap:
true,
// Gzip off by default as many popular static hosts such as
// Surge or Netlify already gzip all static assets for you.
// Before setting to `true`, make sure to:
// npm install --save-dev compression-webpack-plugin
productionGzip:
false,
productionGzipExtensions: [
'js',
'css'],
// Run the build command with an extra argument to
// View the bundle analyzer report after build finishes:
// `npm run build --report`
// Set to `true` or `false` to always turn it on or off
bundleAnalyzerReport:
process.
env.
npm_config_report
},
2. 命令窗口进入vue工程目录,运行 npm run build等项目运行完成,等运行完成。
3. 进入vue工程的dist文件夹,拷贝inedx.html以及项目图标到项目的templates目录,拷贝static下的所有文件到项目的static目录下。
4. Ass-stage新建controller,跳转到项目的index.html页面。
@Controller
@RequestMapping("/")
publicclass *******Controller {
@RequestMapping(path = "/", method =RequestMethod.GET)
public String index() {
System.out.println("进入项目首页....");
return "index";
}
}
5. 输入地址访问项目,如果访问出现js或者css无法找到,则项目中增加config配置文件,配置如下:
@Configuration
publicclass WebMvcConfig extends WebMvcConfigurerAdapter {
@Override
public voidaddResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
}
}
6.重启项目,访问。
所有评论(0)