相较于配置地域spring
springboot连接数据库轻松简单。
在application.yml或properties构建连接数据
mybatis.type-aliases-package=com.jason.hellospring.pojo
mybatis.mapper-locations=classpath:mybatis/mapper/*.xml
(properties中配置mybatis的别名、地址)
spring:
datasource:
username: root
password: ****
url: jdbc:mysql://localhost:3306/ssmbuild?useSSL=false&useUnicode=true&characterEncoding=utf8
driver-class-name: com.mysql.cj.jdbc.Driver
(yml中基本四个数据类型)
在被绑定的mapper文件中注明mapper和repsitory