参考demo
https://github.com/huangzhenshi/demo-ssm
- 在启动类指定MapperScan,避免在每个Dao上写@Mapper
@SpringBootApplication
@MapperScan("com.example.demo.ssm.dao")
public class DemoSsmApplication {
public static void main(String[] args) {
SpringApplication.run(DemoSsmApplication.class, args);
}
}
- 配置
mybatis.mapper-locations=classpath*:mapper/*.xml
mybatis.type-aliases-package=com.example.demo.ssm.entity
# show mybatis sql
logging.level.com.example.demo.ssm.mapper=debug
- 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.10</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.0.25</version>
</dependency>
网友评论