1 、 搭建boot啟動框架,這一步驟什么都不用添加,搭建完后框架如下:

2、因為是前后台項目,所以一般是需要有前台頁面的,需要在后端maven依賴中加入web依賴包
spring-boot-starter-web
所有的后台依賴如下:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.example</groupId> <artifactId>cmstest</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>jar</packaging> <name>cmstest</name> <description>Demo project for Spring Boot</description> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.3.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> </project>
3、 搭建能被boot讀取到的靜態資源目錄,在resources目錄下新建static目錄,boot默認讀取的是static這個目錄下的靜態資源。這個目錄用來存放后面前端的所有代碼,默認顯示index.html

4、啟動項目,訪問8080端口,成功。


5、說明:如果不用啟動后台,只是前端調試,直接在index.html頁面中,右鍵,選用瀏覽器打開就可以訪問頁面。

