"useUnderscoreToCamelCase"设置为false怎么配置
时间: 2023-07-21 13:22:52 浏览: 28
在使用sharding-jdbc时,可以通过在数据源配置中添加属性来修改druid连接池的配置。具体来说,需要添加一个名为"connectionProperties"的属性,将其中的"useUnderscoreToCamelCase"设置为false,例如:
```
spring:
sharding:
datasource:
names: ds0, ds1
ds0:
# 数据库连接信息
...
# druid连接池的配置
connectionProperties: druid.useUnderscoreToCamelCase=false
ds1:
# 数据库连接信息
...
# druid连接池的配置
connectionProperties: druid.useUnderscoreToCamelCase=false
```
这样,就可以在sharding-jdbc中禁用下划线转驼峰的功能,从而正确处理包含下划线的表名和列名。
相关问题
sharding-jdbc不能用下划线
对的,sharding-jdbc不支持使用下划线作为数据库表名或列名的分隔符。这是因为sharding-jdbc底层使用了阿里巴巴的druid连接池,而druid默认是启用了“useUnderscoreToCamelCase”选项的,它会将下划线转换为驼峰式命名,从而导致分库分表路由失败。如果需要在sharding-jdbc中使用下划线,可以修改druid连接池的配置,将“useUnderscoreToCamelCase”选项设置为false。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![gz](https://img-home.csdnimg.cn/images/20210720083447.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![docx](https://img-home.csdnimg.cn/images/20210720083331.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)