vue打包整合到springboot中

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/

4. 訪問:http://localhost:8080/index.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章