移除手动配置mybatis下划线转驼峰

This commit is contained in:
648540858 2023-05-30 10:32:08 +08:00
parent db51c6ae88
commit 7e818d0c07
4 changed files with 49 additions and 6 deletions

View File

@ -58,9 +58,7 @@ spring:
url: jdbc:postgresql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true url: jdbc:postgresql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&serverTimezone=PRC&useSSL=false&allowMultiQueries=true&allowPublicKeyRetrieval=true
username: root username: root
password: 12345678 password: 12345678
mybatis:
configuration:
map-underscore-to-camel-case: true
pagehelper: pagehelper:
helper-dialect: postgresql helper-dialect: postgresql
``` ```
@ -74,9 +72,7 @@ spring:
url: jdbc:kingbase8://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=utf8 url: jdbc:kingbase8://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=utf8
username: root username: root
password: 12345678 password: 12345678
mybatis:
configuration:
map-underscore-to-camel-case: true
pagehelper: pagehelper:
helper-dialect: postgresql helper-dialect: postgresql
``` ```

View File

@ -0,0 +1,36 @@
package com.genersoft.iot.vmp.conf;
import org.apache.ibatis.logging.stdout.StdOutImpl;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import javax.sql.DataSource;
/**
* 配置mybatis
*/
@Configuration
@Order(value=1)
public class MybatisConfig {
@Autowired
private UserSetting userSetting;
@Bean
public SqlSessionFactory sqlSessionFactory(DataSource dataSource) throws Exception {
final SqlSessionFactoryBean sqlSessionFactory = new SqlSessionFactoryBean();
sqlSessionFactory.setDataSource(dataSource);
org.apache.ibatis.session.Configuration config = new org.apache.ibatis.session.Configuration();
if (userSetting.getSqlLog()){
config.setLogImpl(StdOutImpl.class);
}
config.setMapUnderscoreToCamelCase(true);
sqlSessionFactory.setConfiguration(config);
return sqlSessionFactory.getObject();
}
}

View File

@ -48,6 +48,7 @@ public class UserSetting {
private Boolean syncChannelOnDeviceOnline = Boolean.FALSE; private Boolean syncChannelOnDeviceOnline = Boolean.FALSE;
private Boolean sipLog = Boolean.FALSE; private Boolean sipLog = Boolean.FALSE;
private Boolean sqlLog = Boolean.FALSE;
private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE; private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE;
private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE; private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE;
@ -286,4 +287,12 @@ public class UserSetting {
public void setUseCustomSsrcForParentInvite(Boolean useCustomSsrcForParentInvite) { public void setUseCustomSsrcForParentInvite(Boolean useCustomSsrcForParentInvite) {
this.useCustomSsrcForParentInvite = useCustomSsrcForParentInvite; this.useCustomSsrcForParentInvite = useCustomSsrcForParentInvite;
} }
public Boolean getSqlLog() {
return sqlLog;
}
public void setSqlLog(Boolean sqlLog) {
this.sqlLog = sqlLog;
}
} }

View File

@ -194,6 +194,8 @@ user-settings:
sip-use-source-ip-as-remote-address: false sip-use-source-ip-as-remote-address: false
# 是否开启sip日志 # 是否开启sip日志
sip-log: true sip-log: true
# 是否开启sql日志
sql-log: true
# 消息通道功能-缺少国标ID是否给所有上级发送消息 # 消息通道功能-缺少国标ID是否给所有上级发送消息
send-to-platforms-when-id-lost: true send-to-platforms-when-id-lost: true
# 保持通道状态不接受notify通道状态变化 兼容海康平台发送错误消息 # 保持通道状态不接受notify通道状态变化 兼容海康平台发送错误消息