翻阅DruidDataSource源码:
{ String property = properties.getProperty("druid.initConnectionSqls"); if (property != null && property.length() > 0) { try { StringTokenizer tokenizer = new StringTokenizer(property, ";"); setConnectionInitSqls(Collections.list(tokenizer)); } catch (NumberFormatException e) { LOG.error("illegal property 'druid.initConnectionSqls'", e); } } }
设置属性:spring.datasource.druid.initConnectionSqls=set names utf8mb4;即可