本文主要研究一下如何在springboot工程整合vuehtml
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- mvn process-resources --> <plugin> <artifactId>maven-resources-plugin</artifactId> <executions> <execution> <id>copy Vue.js frontend content</id> <phase>generate-resources</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>src/main/resources/static</outputDirectory> <overwrite>true</overwrite> <resources> <resource> <directory>${basedir}/vue-demo/dist</directory> <includes> <include>static/</include> <include>index.html</include> </includes> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> </build>
在springboot工程整合vue的話,將靜態文件拷貝到src/main/resources/static目錄下便可,這樣就能夠在springboot工程打開靜態文件了,對api的請求也無需再轉發,也沒有跨域問題,比較適合管理後臺前端資源的整合。前端