1.修改vuejs的config/index.js,在裏面找到assetsPublicPath,改爲/,記住,是build:{}這裏的,不是上面dev:{}的
build: {
// Template for index.html
index: path.resolve(__dirname, '../dist/index.html'),
// Paths
assetsRoot: path.resolve(__dirname, '../dist'),
assetsSubDirectory: 'static',
assetsPublicPath: '/',
2. springboot的resources下創建static文件夾,把vue打包出來的static和index.html放進去
3.添加pom
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
4.訪問靜態資源
server.resources.static-locations=classpath:/static/