mybatis的xml文件格式
- mybatis的xml文件格式,用来写sql语句,需要在相同的目录结构下写xml文件
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--命名空间:找到所在的mapper接口的位置-->
<mapper namespace="com.zhou.springbootdemo1.mapper.UserMapper">
<!--sql语句代码-->
</mapper>
- 先要xml文件能够被SpringBoot扫描到,需要配置文件中进行配置
mybatis:
#能够是自己写的xml文件被SpringBoot扫描到
mapper-locations: classpath:mapper/*.xml
#打开mybatis的日志功能
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl