在Spring Boot项目中使用tk.mybatis时,需要在application.yml中配置相关信息。
示例配置:
<em>mybatis</em>: mapper-locations: classpath:mapper/*.xml # mapper<em>文件</em>路径 configuration: map-underscore-to-camel-case: true # 下划线转驼峰 # tk.<em>mybatis</em><em>配置</em> mapper: mappers: - tk.<em>mybatis</em>.mapper.common.Mapper # 通用Mapper not-empty: true # insert语句不插入null值 identity: MYSQL # 主键自增类型
讯享网
说明:
<em>mybatis</em>.mapper-locations:mapper文件路径,可以使用通配符,例如classpath:mapper//*.xml。<em>mybatis</em>.configuration.map-underscore-to-camel-case:是否开启下划线转驼峰功能。<em>mybatis</em>.mapper.mappers:需要使用的通用Mapper接口,可以配置多个。<em>mybatis</em>.mapper.not-empty:insert语句是否插入null值。<em>mybatis</em>.mapper.identity:主键自增类型,可选值为MYSQL、<em>ORACLE</em>等。
注意:
- 在使用tk.mybatis时,需要在mapper接口上加上
@Mapper注解。 - 在mapper.xml文件中,需要使用
tk.<em>mybatis</em>.mapper.common.Mapper接口中的方法,例如insertSelective、selectByPrimaryKey等。

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/146366.html