主要介绍
springboot整合mybatis后application.yml文件里的配置
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: com.zlp.cps.entity
configuration:
map-underscore-to-camel-case: true
详细介绍
- mapper-locations: classpath:mapper/*.xml
使我们的mapper接口和mapper.xml文件形成映射关系
- type-aliases-package: com.zlp.cps.entity
使我们mapper.xml文件中的parameterType、resultType使用到的实体类可以不用写全限定类名
例如:
<!--
com.zlp.cps.entity.po.TbMaterial也可以直接写成TbMaterial
-->
<select id="selectTbMaterialByMatid" resultType="com.zlp.cps.entity.po.TbMaterial">
select <include refid="base_tb_material"/>
from tb_material
where material_id = #{materialId}
</select>
- configuration:
map-underscore-to-camel-case: true
开始使用驼峰命名规则,也就是你的数据使用字段是material_type可以和实体里中的materialType形成映射关系
如果不开启驼峰命名规则,必须使用resultMap来手动建立映射关系