简体   繁体   English

springboot map-underscore-to-camel-case无效

[英]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.

相关问题 无法使用 Jackson 将下划线大小写转换为驼色大小写 - Not able to convert underscore case to camel case with Jackson 下划线为驼峰式,某些前缀除外 - Underscore to camel case except for certain prefixes 在 Intellij 中,如何在驼峰大小写和下划线分隔之间切换? - In Intellij, how do I toggle between camel case and underscore spaced? 在 springboot 应用程序中的 H2 db 中创建表和列时,无法将骆驼案例转换为蛇案例 - Not able to convert camel case to snake case while creating tables and columns in H2 db in a springboot application 使用@ConfigurationProperties 从 YAML 文件分配 map 时,如何将键从脊椎案例转换为驼峰案例 - How to convert keys from spinal case to camel case when using @ConfigurationProperties to assign a map from a YAML file SpringBoot Camel SendBody()路由未发送 - SpringBoot Camel SendBody() routes not sending 如何 map Hibernate 实体字段使用camelCase到snake_case(下划线)数据库标识符 - How to map Hibernate entity fields using camelCase to snake_case (underscore) database identifiers Web资源中的Camel案例 - Camel case in web resources 骆驼盒正则表达式不起作用 - Camel case regex not working 在Apache Camel中切换案例 - Switch case in Apache Camel
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM