springboot中mybatis设置下划线和驼峰转换


转自:https://www.jianshu.com/p/bf2c129e2866

springboot项目中使用mybatis

pom文件中增加starter

        <dependency>
            <groupId>org.mybatis.spring.boot</groupId>
            <artifactId>mybatis-spring-boot-starter</artifactId>
            <version>2.1.2</version>
        </dependency>

启动类上,增加@MapperSacen注解

@MapperScan("com.example.mapper")

在com.example.mapper包下编写Mapper接口

可以通过设置以下属性,完成数据库中表字段(下划线)和java bean(驼峰)的映射。

mybatis.configuration.map-underscore-to-camel-case=true




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM