2017-08-07 25 views
1

GrailsプロジェクトからMySQLデータベースに接続しようとしていますが、まだ管理していません。Grails 3.3をmysqlデータベースに接続できません

私は、次のバージョンであるIntelliJ IDEAの17に取り組んでいます:

| Grails Version: 3.3.0.RC1 
| Groovy Version: 2.4.12 
| JVM Version: 1.8.0_131 

build.gradle

dependencies{ 
    compile files ("lib/mysql-connector-java-5.1.43-bin") 
} 

application.yml

hibernate: 
    cache: 
     queries: false 
     use_second_level_cache: false 
     use_query_cache: false 
dataSource: 
    pooled: true 
    jmxExport: true 
    driverClassName: com.mysql.jdbc.Driver 
    dialect: org.hibernate.dialect.MySQL5InnoDBDialect 
    username: root 
    password: '' 

environments: 
    development: 
     dataSource: 
      dbCreate: create-drop 
      url: jdbc:mysql:3306//localhost/mydatabase 
    test: 
     dataSource: 
      dbCreate: update 
      url: jdbc:mysql:3306//localhost/mydatabase 
    production: 
     dataSource: 
      dbCreate: none 
      url: jdbc:mysql:3306//localhost/mydatabase 

のエラー

"C:\Program Files\Java\jdk1.8.0_131\bin\java" -XX:+TieredCompilation -XX:TieredStopAtLevel=1 -XX:CICompilerCount=3 -Djline.WindowsTerminal.directConsole=false -Dfile.encoding=UTF-8 -classpath C:\Users\Vaggelis\AppData\Local\Temp\classpath.jar org.grails.cli.GrailsCli run-app 
|Resolving Dependencies. Please wait... 

CONFIGURE SUCCESSFUL 

Total time: 3.824 secs 
|Running application... 
2017-08-07 19:42:52.921 ERROR --- [   main] o.a.tomcat.jdbc.pool.ConnectionPool  : Unable to create initial connections of pool. 

java.sql.SQLException: Unable to load class: com.mysql.jdbc.Driver from ClassLoader:[email protected];ClassLoader:[email protected] 

2017-08-07 19:42:55.391 ERROR --- [   main] o.h.engine.jdbc.spi.SqlExceptionHelper : Unable to load class: com.mysql.jdbc.Driver from ClassLoader:[email protected];ClassLoader:[email protected] 
2017-08-07 19:42:55.405 ERROR --- [   main] o.s.b.f.s.DefaultListableBeanFactory  : Destroy method on bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor' threw an exception 

2017-08-07 19:42:55.431 ERROR --- [   main] o.s.boot.SpringApplication    : Application startup failed 

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'methodValidationPostProcessor' defined in class path resource [org/springframework/boot/autoconfigure/validation/ValidationAutoConfiguration.class]: Unsatisfied dependency expressed through method 'methodValidationPostProcessor' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.exception.GenericJDBCException: Unable to check JDBC Connection auto-commit in preparation for DDL execution 

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastoreServiceRegistry': Cannot resolve reference to bean 'hibernateDatastore' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'hibernateDatastore': Bean instantiation via constructor failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.exception.GenericJDBCException: Unable to check JDBC Connection auto-commit in preparation for DDL execution 

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.grails.orm.hibernate.HibernateDatastore]: Constructor threw exception; nested exception is org.hibernate.exception.GenericJDBCException: Unable to check JDBC Connection auto-commit in preparation for DDL execution 

Caused by: org.hibernate.exception.GenericJDBCException: Unable to check JDBC Connection auto-commit in preparation for DDL execution 

FAILURE: Build failed with an exception. 

What went wrong: 
Execution failed for task ':bootRun'. 
Process 'command 'C:\Program Files\Java\jdk1.8.0_131\bin\java.exe'' finished with non-zero exit value 1 

Try: 
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. 
Error | 
Failed to start server (Use --stacktrace to see the full trace) 

Process finished with exit code 1 

MySQLConnectorは正しくインポートされているので、どこかで私は、データソース内の誤ったデータを入力しておく必要があります。

+0

が重複する可能性 - のGradleの依存性MySQLをコネクタ](https://stackoverflow.com/questions/33386020/grails-3-gradle-dependecies-mysql-connector) –

+0

デフォルトではなくGrails 3.0を追加しようとしましたが、それでも同じです –

+0

in grails 3 dialect in hibernateデータソースではありません。 –

答えて

1

私は、この設定を使用していますし、それが正常に働いています:

build.gradle

dependencies { 
    runtime 'mysql:mysql-connector-java:5.1.29' 
} 

3方言を下に指定されているのGrailsで

hibernate: 
    cache: 
     queries: false 
     use_second_level_cache: true 
     use_query_cache: false 
     region.factory_class: org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory 


dataSource: 
    pooled: true 
    jmxExport: true 


environments: 
    development: 
     dataSource: 
      dbCreate: create-drop 
      url: "jdbc:mysql://localhost:3306/mydb?autoReconnect=true" 
      driverClassName: "com.mysql.jdbc.Driver" 
      dialect: org.hibernate.dialect.MySQL5InnoDBDialect 
      username: "yyyyy" 
      password: "xxxxx" 
+0

ええと、dataSourceの初期設定を削除して、あなたのような開発/データソースに追加しようとしましたが、「Grails CLIを実行中にエラーが発生しました:マッピング値はここで許可されていません。どのようにあなたにはうまくいったのか分かりませんが、うまく動作してからH2 dbに行くと思います。 –

+0

コピー/ペースト後にインデントがオフになっていました。私はそれを訂正し、今動作するかどうかを確認します。 –

1

application.ymlセクションを休止し、データソースの下にはありません。

hibernate: 
    dialect: org.hibernate.dialect.MySQL5InnoDBDialect 
1

私はabstractドメインクラスの2からtablePerConcreteClassマッピング取り除くで私のGrails 3.2.9のプロジェクトで同様の問題を修正:[Grailsの3の

static mapping = { 
    tablePerConcreteClass true 
} 
関連する問題