时间:2021-07-01 10:21:17 帮助过:2人阅读
完整配置参考下面:
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close"> <property name="driverClassName" value="${jdbc-driver}"/> <property name="url" value="${jdbc-url}"/> <property name="username" value="${jdbc-user}"/> <property name="password" value="${jdbc-password}"/> <property name="filters" value="stat"/> <property name="maxActive" value="20"/> <property name="initialSize" value="1"/> <property name="maxWait" value="60000"/> <property name="minIdle" value="1"/> <property name="timeBetweenEvictionRunsMillis" value="3000"/> <property name="minEvictableIdleTimeMillis" value="300000"/> <property name="validationQuery" value="SELECT ‘x‘"/> <property name="testWhileIdle" value="true"/> <property name="testOnBorrow" value="false"/> <property name="testOnReturn" value="false"/> <property name="poolPreparedStatements" value="true"/> <property name="maxPoolPreparedStatementPerConnectionSize" value="20"/> <property name="connectionInitSqls" value="set names utf8mb4;"/> </bean>
基本上应该就可以了,如果还不行,检查下jdbc连接串的设置:
jdbc:mysql://localhost:3306/db名称?useUnicode=true&characterEncoding=utf8
再不行的话,把最后的?useUnicode=true&characterEncoding=utf8 去掉
mysql : utf8mb4 的问题
标签: