会用到的配置信息

一些常用配置信息

配置文件信息


SpringBoot的Application.yml配置

注解:

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
33
34
35
#指定Tomcat服务器的端口
server:
port: 8080


#设定该路径下的最小日志等级
#这样的配置允许以分层的方式为不同的包和类设置日志级别
logging:
level:
com:
kangkang: debug

#spring:
# datasource:
# 设置数据库驱动类的全限定类名。在这里,指定了 MySQL 的驱动类。
# driver-class-name: com.mysql.cj.jdbc.Driver
# 设置数据库连接的 URL。这里是连接到 MySQL 数据库的 URL,
# -包括主机地址(127.0.0.1),端口号(3306),数据库名(springboot),以及其他一些连接属性(如字符集、时区等)。
# url: jdbc:mysql://127.0.0.1:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
# 数据库的用户名
# username: root
# 数据库的密码
# password: 123456

#mybatis:
# configuration:
# #开启驼峰映射 将数据库下划线的字段名映射为java的驼峰命名规则
# map-underscore-to-camel-case: true
# #指定MyBatis的日志实现。指定为StdOutImpl
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
# #指定用于MyBatis的类型别名的基础包路径。这意味着MyBatis将扫描此包及其子包,查找用于类型别名的类。
# type-aliases-package: com.kangkang.boot.domain
# 指定Mapper XML文件的位置。在这里,classpath:mapper/**/*Mapper.xml
# -表示MyBatis将在类路径下的 mapper 文件夹及其所有子文件夹中查找所有以 Mapper.xml 结尾的文件。这些文件通常包含MyBatis的SQL映射配置。
# mapper-locations: classpath:mapper/**/*Mapper.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24

server:
port: 8080


logging:
level:
com:
kangkang: debug

spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://127.0.0.1:3306/springboot?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&allowPublicKeyRetrieval=true
username: root
password: 123456


mybatis:
configuration:
map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
type-aliases-package: com.kangkang.boot.domain
mapper-locations: classpath:mapper/**/*Mapper.xml

Mybatis Mpper.xml文件配置

注解:

1
2
3
4
5
6
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN": 这是一个文档类型声明(DOCTYPE declaration),指定了 XML 文档的 DTD(文档类型定义)。在这里,它指定了 MyBatis 3.0 版本的 Mapper DTD

"http://mybatis.org/dtd/mybatis-3-mapper.dtd">: 这部分是 DTD 的具体位置。DTD 文件包含了定义 MyBatis XML 文档结构的规范。

<mapper namespace="com.kangkang.boot.mapper.StudentMapper">: 这是 Mapper XML 文件的根元素,定义了该文件的命名空间。在这里,namespace 属性指定了该 Mapper 文件所属的命名空间,通常与对应的 Mapper 接口的全限定名一致,以便 MyBatis 可以将该 XML 文件与正确的 Mapper 接口关联起来。

代码:

1
2
3
4
5
6

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kangkang.boot.mapper.StudentMapper">

</mapper>

会用到的配置信息
http://example.com/2024/01/23/Tool/
作者
kangkang
发布于
2024年1月23日
许可协议