右键new>>>other
next,
finish,
pom文件,
<?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>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.springboot</groupId>
<artifactId>TestBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring</name>
<description>Demo project for Spring Boot</description>
<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-test</artifactId>
<scope>test</scope>
</dependency>
<!-- web 模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- webservice 模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
</dependency>
<!-- websocket 模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-websocket</artifactId>
</dependency>
<!-- thymeleaf 模板引擎 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
<!-- mail 模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-mail</artifactId>
</dependency>
<!-- mysql 模块 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<!-- mybatis 模块 -->
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
<!-- test 模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- 热部署模块 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>false</optional> <!-- 这个需要为 true 热部署才有效 -->
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
添加,目录,
static存放js,css。templates存放HTML。配置文件写入application.yml
server:
port: 8080
servlet:
context-path: /boot
# =====================数据源配置===========================
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/ssm?characterEncoding=utf8
username: root
password: root
driver-class-name: com.mysql.cj.jdbc.Driver
# =====================热部署配置===========================
devtools:
restart:
#热部署生效
enabled: true
#设置重启的目录
#additional-paths: src/main/java
#排除那个目录的文件不需要restart
exclude: config/**,templates/**,static/**
# =====================Thymeleaf 配置===========================
thymeleaf:
enabled: true # 是否启用thymeleaf模板解析
cache: false # 是否开启模板缓存(建议:开发环境下设置为false,生产环境设置为true)
check-template-location: true # Check that the templates location exists.
servlet:
content-type: text/html # 模板的媒体类型设置,默认为text/html
encoding: UTF-8 # 模板的编码设置,默认UTF-8
characterEncoding: UTF-8
#view-names: # 设置可以被解析的视图,以逗号,分隔
#excluded-view-names: # 排除不需要被解析视图,以逗号,分隔
#mode:HTML5 # 模板模式设置,默认为HTML5
prefix: classpath:/templates/ # 前缀设置,SpringBoot默认模板放置在classpath:/template/目录下
suffix: .html # 后缀设置,默认为.html
#template-resolver-order: # 模板在模板链中被解析的顺序
jmx:
# enabled: false
default-domain: springboottest
logging:
path: F:\JavaFiles\logs\spring boot\logs
level:
com.springboottest.dao: DEBUG