概况
主要在于 mapper-locations 和pom中的区别。
- mapper-locations 跟据自己实际的位置写。
- idea编辑器下。如果xml文件放在了java目录则需要配置下面资源目录。否则无需配置。
application.yaml
mybatis-plus:
global-config: #全局配置
db-config: #数据库配置
id-type: auto #主键id自增
configuration: #原来的mybais的配置
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl #开启sql日志
mapper-locations: classpath:com/example/demo/mapper/xml/*.xml #映射xml文件位置
type-aliases-package: com.example.demo.entity #实体类包名
pom
<build>
<resources>
<resource>
<!-- xml放在java目录下-->
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<!--自定义resource之后 默认值失效,必须重新指定-->
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>