[英]springboot map-underscore-to-camel-case invalid
My spring version is 1.5.2, spring-mybatis-start version is 1.3.2, I set mybatis.configuration.map-underscore-to-camel-case=true
in properties. 我的春季版本是1.5.2,spring-mybatis-start版本是1.3.2,我在属性中设置了mybatis.configuration.map-underscore-to-camel-case=true
。 But the MAP I returned was not converted to Camel named 但是我返回的MAP并未转换为名为Camel的骆驼
Here is my configuration 这是我的配置
mybatis.configuration.map-underscore-to-camel-case=true
The problem has been sovled,the plan is as follows 问题已解决,计划如下
public class CustomWrapper extends MapWrapper{
public CustomWrapper(MetaObject metaObject, Map<String, Object> map) {
super(metaObject, map);
}
// useCamelCaseMapping is map-underscore-to-camel-case field
@Override
public String findProperty(String name, boolean useCamelCaseMapping) {
if(useCamelCaseMapping){
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL,name);
}
return name;
}
}
public class MapWrapperFactory implements ObjectWrapperFactory {
@Override
public boolean hasWrapperFor(Object object) {
return object != null && object instanceof Map;
}
@Override
public ObjectWrapper getWrapperFor(MetaObject metaObject, Object object) {
return new CustomWrapper(metaObject,(Map)object);
}
}
@Configuration
public class MybatisConfig {
@Bean
public ConfigurationCustomizer mybatisConfigurationCustomizer(){
return new ConfigurationCustomizer() {
@Override
public void customize(org.apache.ibatis.session.Configuration configuration) {
configuration.setObjectWrapperFactory(new MapWrapperFactory());
}
};
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.