MBG 配置 mysql
<classPathEntry location="./mysql-connector-java-5.1.40.jar" />
<jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="123455"> </jdbcConnection>
如果报错
Exception in thread "main" java.lang.RuntimeException: Exception getting JDBC Driver
at org.mybatis.generator.internal.db.ConnectionFactory.getDriver(ConnectionFactory.java:85)
at org.mybatis.generator.internal.db.ConnectionFactory.getConnection(ConnectionFactory.java:54)
at org.mybatis.generator.config.Context.getConnection(Context.java:526)
at org.mybatis.generator.config.Context.introspectTables(Context.java:436)
at org.mybatis.generator.api.MyBatisGenerator.generate(MyBatisGenerator.java:222)
at org.mybatis.generator.api.ShellRunner.main(ShellRunner.java:117)
Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:274)
at org.mybatis.generator.internal.ObjectFactory.internalClassForName(ObjectFactory.java:150)
at org.mybatis.generator.internal.ObjectFactory.externalClassForName(ObjectFactory.java:121)
at org.mybatis.generator.internal.db.ConnectionFactory.getDriver(ConnectionFactory.java:82)
... 5 more
①检查classPathEntry 是否配置正确
②查看mysql 数据库版本
SELECT VERSION() from dual;
如果是 5.xx 需要下载对应5的驱动
如果报错
Wed Apr 18 14:00:43 CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
需要在
connectionURL后追加?useSSL=false