Springboot工程常用配置

Springboot工程常用配置

yml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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


#mybatis-plus:
# mapper-locations: classpath*:/dao/**/*Dao.xml
# configuration:
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl


xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#关闭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
#Mybatis配置

#日志配置
logging:
level:
root: info
com.xuda: debug

#指定文件上传的位置
photo:
file:
dir: D:\__easyProjects__\IntelliJ_IDEA\SpringBootStudy\photo

打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2022-2024 何福海
  • 访问人数: | 浏览次数:

请我喝杯奶茶吧~

支付宝
微信