1. 程式人生 > >專案中mybatis連線mysql常見問題

專案中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 XXX\src\main\java\generator\generatorConfig.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:\Users\Administrator\.m2\repository\mysql\mysql-connector-java\5.2.46\mysql-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:\Users\Administrator\.m2\repository), 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]';