1.使用环境
spring-boot:2.1.4.RELEASE
2.使用过程。
在main下的mapper的中写mapper.class文件。
2.1 使用@mapper
在mapper.class 文件中使用@mapper即可。
2.2 使用@MapperScan
在启动类中加入@MapperScan("xxx.xxx.mapper"), 地址为mapper.java所放的目录。mapper.java不用任何处理。
3.mapperxml配置
3.1 在pom.xml 文件中加入
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>
改变mapper.xml文件只能存放resource文件夹下的规则。扫描源码路径。
3.2 在application.properties文件中加mybatis.mapper-locations=classpath*:/mapper/*.xml
配置/resource 文件夹下的多文件源扫描,用,隔开。