前言
Spring简化了Java的开发,而SpringBoot简化了Spring。本文用SpringBoot采用分层的结构整合了filter,aspect,mybaits,logback,redis,rocketmq和dubbo等框架。这是一个比较接近实际项目的版本。
mybaits
在application.properties配置数据源和目录就行了,不用配置SqlSessionFactory和TransactionManager,如下
#mysql
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/mysql?serverTimezone=GMT%2B8
spring.datasource.username=root
spring.datasource.password=111111
# mybatis
# mybatis.config-location=classpath:/mybatis/mybatis-config.xml
mybatis.mapper-locations=classpath*:/mappers/*.xml
mybatis.type-aliases-package=com.example.demo.repository.entity
另外还需要设置MapperScan,如
@SpringBootApplication(scanBasePackages = "com.example.demo")
@MapperScan("