项目中mybatis连接mysql常见问题
Posted hangtutu
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了项目中mybatis连接mysql常见问题相关的知识,希望对你有一定的参考价值。
参考:https://blog.csdn.net/qq_40943363/article/details/82633906
1.pom.xml文件中指定的generatorConfig.xml文件路径不对
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.343 s [INFO] Finished at: 2018-09-11T21:50:29+08:00 [INFO] Final Memory: 13M/115M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate (default-cli) on project springboot-mybatis: configfile XXXsrcmainjavageneratorgeneratorConfig.xml does not exist -> [Help 1]
2.generatorConfig.xml文件中的数据库驱动路径写错
<classPathEntry location="/Users/xxx/.m2/repository/mysql/mysql-connector-java/5.1.30/mysql-connector-java-5.1.30.jar"/>
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.189 s [INFO] Finished at: 2018-09-11T22:23:34+08:00 [INFO] Final Memory: 14M/115M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate (default-cli) on project springboot-mybatis: Execution default-cli of goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate failed: Cannot resolve classpath entry: C:UsersAdministrator.m2 epositorymysqlmysql-connector-java5.2.46mysql-connector-java-5.1.46.jar -> [Help 1]
3.generatorConfig.xml文件中的连接数据账号密码写错
<!--mysql数据库连接--> <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://localhost:3306/test" userId="root" password="password"/>
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2.250 s [INFO] Finished at: 2018-09-11T22:30:42+08:00 [INFO] Final Memory: 16M/115M [INFO] ------------------------------------------------------------------------ [ERROR] Failed to execute goal org.mybatis.generator:mybatis-generator-maven-plugin:1.3.2:generate (default-cli) on project springboot-mybatis: Access denied for user ‘root‘@‘localhost‘ (using password: YES) -> [Help 1]
4.pom.xml文件中的没有添加mybatis插件
<plugins> <plugin> <groupId>org.mybatis.generator</groupId> <artifactId>mybatis-generator-maven-plugin</artifactId> <version>1.3.2</version> <configuration> <!--mybatis用于生成代码的配置文件--> <configurationFile>src/main/resources/generatorConfig.xml</configurationFile> <verbose>true</verbose> <overwrite>true</overwrite> </configuration> </plugin> </plugins>
[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 13.913 s [INFO] Finished at: 2018-09-11T22:37:47+08:00 [INFO] Final Memory: 26M/183M [INFO] ------------------------------------------------------------------------ [ERROR] No plugin found for prefix ‘mybatis-generator‘ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (C:UsersAdministrator.m2 epository), central
5. mysql8 :客户端连接caching-sha2-password问题
参考:https://blog.csdn.net/u010026255/article/details/80062153
注意mysql新版本密码需要复杂些,要包含大写小写数字或者特殊符号
ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘这里写密码‘ PASSWORD EXPIRE NEVER; #修改加密规则 ALTER USER ‘root‘@‘localhost‘ IDENTIFIED WITH mysql_native_password BY ‘这里写密码‘; #更新一下用户的密码 FLUSH PRIVILEGES; #刷新权限
6.Mysql 8授权语句
create user ‘[email protected]‘ identified by ‘Password‘; grant all privileges on *.* to ‘[email protected]‘;
以上是关于项目中mybatis连接mysql常见问题的主要内容,如果未能解决你的问题,请参考以下文章
如何用IDEA创建springboot(maven)并且整合mybatis连接mysql数据库和遇到的问题
idea springboot中整合jdbc连接MySQL中,Schemas中无mybatis怎么解决?
连接MySQL出现错误:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: YES)(代码片段