Springboot项目常用配置
yml
server:
port: 9090
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/db_crud?serverTimezone=GMT%2b8
username: root
password: password
mybatis:
mapper-locations: classpath:mapper/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
xml
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.example.springboot.mapper.BooksMapper">
<select id="list" resultType="com.example.springboot.entity.Books">
select *
from sys_books;
</select>
<select id="selectPage" resultType="com.example.springboot.entity.User">
select *
from sys_books limit #{pageNum},#{pageSize};
</select>
<select id="selectTotal" resultType="java.lang.Integer">
select count(*)
from sys_books
</select>
</mapper>
thymeleaf
spring:
thymeleaf:
cache: false
prefix: classpath:/templates/
suffix: .html
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/ssmbuild?characterEncoding=UTF-8
username: root
password: password
web:
resources:
static-locations: classpath:/static/,file:${photo.file.dir}
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.xuda.springboot.pojo
logging:
level:
root: info
com.xuda: debug
photo:
file:
dir: D:\__easyProjects__\IntelliJ_IDEA\SpringBootStudy\photo