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