<dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.0.5</version> </dependency>
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.14</version> </dependency>
類上添加註解 @MapperScan
java
@SpringBootApplication @MapperScan("com.dylan.dylanmybatisstarter.pre") public class DylanMybatisStarterApplication { public static void main(String[] args) { SpringApplication.run(DylanMybatisStarterApplication.class, args); } }
#mysql鏈接 spring.datasource.driverClassName=com.mysql.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf-8 spring.datasource.username=root spring.datasource.password=root mybatis.type-aliases-package=com.dylan.dylanmybatisstarter.pre # 掃描實體類 mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl #打印sql
實現 BaseMapper
類mysql
@Repository public interface LogDao extends BaseMapper<DylanLog>{ }