通用mapper + spring boot 駝峯轉下劃線

mybatis:
  type-aliases-package: 指向實體類
  mapper-locations: 指向 .xml
  configuration:
    map-underscore-to-camel-case: true​

 

//多數據源
@Bean(name = "xxxxxxxxx")
@Primary
public SqlSessionFactory sqlSessionFactory(@Qualifier("xxxxxxxxx") DataSource dataSource) throws Exception {
    SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
    bean.setDataSource(dataSource);
    org.apache.ibatis.session.Configuration configuration=new org.apache.ibatis.session.Configuration();
    configuration.setMapUnderscoreToCamelCase(true);
    bean.setConfiguration(configuration);
    bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("xxxxxxxxx"));
    return bean.getObject();
}

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章