idea用mybaits连接mysql_IDEA使用mybatis-generator及配上mysql8.0.3版本遇到的bug

1.添加插件,在pom文件的下的添加以下配置

org.mybatis.generator

mybatis-generator-maven-plugin

1.3.5

true

true

mysql

mysql-connector-java

8.0.11

2.在resources下创建generatorConfig.xml,内容如下:

/p>

PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"

"http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">

connectionURL="jdbc:mysql://localhost:3306/wg_insert?useUnicode=true&characeterEncoding=utf-8&serverTimezone=UTC" userId="root"

password="123456">

targetProject="src/main/java">

targetProject="src/main/resources">

targetPackage="com.wglvzyx.mybatisredis.dao" targetProject="src/main/java">

enableCountByExample="false" enableUpdateByExample="false"

enableDeleteByExample="false" enableSelectByExample="false"

selectByExampleQueryId="false">

3.运行,这里有两种方法:

方法一:

在Intellij IDEA添加一个“Run运行”选项,使用maven运行mybatis-generator-maven-plugin插件 (mybatis-generator:generate -e):

aa43de0cf9327131c6f443117b4ae735.png

方法二:

在右侧打开maven面板在Plugins下打开Mybatis-generator下的mybatis-generator:generate,右键Run Maven Build!

71c3e7ead4d3236d5423bf0a94a6c03e.png

注意:

因为用的是mysql-8.0.11

所以配置有所不同

主要就是新版本有新特性,首先,最新官方支持将com.mysql.jdbc.Driver改为com.mysql.cj.jdbc.Driver,此外mysql8.0是不需要建立ssl连接的,你需要显示关闭,即url中的useSSL=false;最后你需要设置CST,CST可视为美国、澳大利亚、古巴或中国的标准时间。serverTimezone是设置时区的,大家可以查一下相关资料了解一下哦!

jdbc.driverClassName=com.mysql.cj.jdbc.Driver

jdbc.url=jdbc:mysql://localhost:3306/mytest?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=UTC

jdbc.username=root

jdbc.password=123456

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值