jpa映射实体类后,驼峰字段取值为null

<!--jpa-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>

配置完jpa以后自动生成实体类spring

以后测试时出现了驼峰字段的值为null,而像id之类的非驼峰字段却有值mybatis

解决思路app

非驼峰字段有值说明数据是取到了,经过断点调试发现userName字段的set()方法没走,大概能猜出实体类映射出了问题spring-boot

解决方案测试

pom.xml添加调试

<!--驼峰映射-->
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-configuration-processor</artifactId>
    <optional> true</optional>
</dependency>

application添加xml

#驼峰映射
mybatis.configuration.map-underscore-to-camel-case=true
相关文章
相关标签/搜索