springboot 使用mybatis (xml Mapper)

1、POM

<dependency>
    <groupId>org.mybatis.spring.bootgroupId>
    <artifactId>mybatis-spring-boot-starterartifactId>
    <version>1.3.0version>
dependency>


<dependency>
    <groupId>org.springframework.bootgroupId>
    <artifactId>spring-boot-starter-jdbcartifactId>
    <exclusions>
        <exclusion>
            <groupId>org.apache.tomcatgroupId>
            <artifactId>tomcat-jdbcartifactId>
        exclusion>
    exclusions>
dependency>

2、定义datasource bean

3、application.properties

mybatis.mapper-locations=classpath*:mapper/*.xml
mybatis.type-aliases-package=com.XX.entity

定义xml文件位置,别名位置

4、在启动文件,写注解:

@SpringBootApplication
@MapperScan("com.wd.mybatis.mapper")


你可能感兴趣的:(springboot 使用mybatis (xml Mapper))