看到社区里好几人提问jfinal如何连接mysql8,现分享一下。
拿jfinal3.5版本的demo,jfinal_demo_for_maven为例子,mysql版本为8.0.12:
1、修改pom.xml里的mysql驱动坐标
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.12</version> </dependency>
2、修改DemoConfig.java
// 配置 druid 数据库连接池插件 DruidPlugin druidPlugin = new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password").trim(),"com.mysql.cj.jdbc.Driver");
3、修改a_little_config.txt
jdbcUrl = jdbc:mysql://localhost/jfinal_demo?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&serverTimezone=GMT
打完收工!
感谢分享