1 要使用zuul就要有容器,那么IDEA社区版运行Tomcat首先使用maven的插件,结果各种jar冲突,弃之

  之后使用插件smart Tomcat搞定

2 mysql的driver已经从com.mysql.cj.jdbc.MysqlDataSource改为了com.mysql.cj.jdbc.MysqlDataSource

3 由于时区问题无法连接默认的时区是SYSTEM,网上查了很多方法要修改连接URL,为了一劳永逸直接改了MySQL时区

> set global time_zone = '+8:00'; ##修改mysql全局时区为北京时间,即我们所在的东8区

> set time_zone = '+8:00'; ##修改当前会话时区

> flush privileges; #立即生效

> show variables like "%time_zone%";

4 人懒直接抄了HikariCP官网的配置

 

HikariConfig config = new HikariConfig();
config.setJdbcUrl("jdbc:mysql://localhost:3306/simpsons");
config.setUsername("bart");
config.setPassword("51mp50n");
config.addDataSourceProperty("cachePrepStmts", "true");
config.addDataSourceProperty("prepStmtCacheSize", "250");
config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

HikariDataSource ds = new HikariDataSource(config);

之后拼命的报unable to to select database的 SQL Exception

改成下面的样子就OK了

public JDBCZuulFilterDaoBuilder() {
   HikariConfig config = new HikariConfig();
   config.setDataSourceClassName("com.mysql.cj.jdbc.MysqlDataSource");
   //config.setJdbcUrl("jdbc:mysql://localhost:3306/spring2go_zuul_filter?characterEncoding=utf-8&useSSL=false");
   config.addDataSourceProperty("url", url.get());
   config.addDataSourceProperty("user", user.get());
   config.addDataSourceProperty("password", password.get());
   //config.setUsername("root");
   //config.setPassword("root");
   config.setSchema("spring2go_zuul_filter");
   config.addDataSourceProperty("cachePrepStmts", "true");
   config.addDataSourceProperty("prepStmtCacheSize", "250");
   config.addDataSourceProperty("prepStmtCacheSqlLimit", "2048");

   this.dataSource = new HikariDataSource(config);
   this.filterTable = filterTableName.get(); //+ "_" + environment.get();
}
Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐