2016-01-15 6 views
5

私はIntelliJ IDEA 15.0.2をIDEとして使用しています。私はGrails 3.0アプリケーションを作成し、それを少し変更してPostgreSQLを設定しました。ここでGrails 3.0でPostgreSQLを設定するにはどうすればよいですか?

は私のデータソースです:

dataSource: 
pooled: true 
jmxExport: true 
driverClassName: org.postgresql.Driver 
username: postgres 
password: root 

environments: 
development: 
    dataSource: 
     dbCreate: update 
     url: jdbc:postgresql://localhost:5432/trace_db 
test: 
    dataSource: 
     dbCreate: update 
     url: jdbc:postgresql://localhost:5432/trace_db 
production: 
    dataSource: 
     dbCreate: update 
     url: jdbc:postgresql://localhost:5432/trace_db 
     properties: 
      jmxEnabled: true 
      initialSize: 5 
      maxActive: 50 
      minIdle: 5 
      maxIdle: 25 
      maxWait: 10000 
      maxAge: 600000 
      timeBetweenEvictionRunsMillis: 5000 
      minEvictableIdleTimeMillis: 60000 
      validationQuery: SELECT 1 
      validationQueryTimeout: 3 
      validationInterval: 15000 
      testOnBorrow: true 
      testWhileIdle: true 
      testOnReturn: false 
      jdbcInterceptors: ConnectionState 
      defaultTransactionIsolation: 2 # TRANSACTION_READ_COMMITTED 

そして、私のbuild.gradleで私はruntime "postgresql:postgresql:9.4-1207.jdbc4"を追加しました。

しかし、私は実行したときに、それはエラーを与える:

ERROR org.apache.tomcat.jdbc.pool.ConnectionPool - Unable to create initial connections of pool. 
java.sql.SQLException: org.postgresql.Driver 

私が見逃している何?

+1

クラスパスにpostgresql JDBCドライバがありますか? –

+0

1つの答えを受け入れてください。 –

答えて

4

データソース

dataSource { 
    pooled = true 
    jmxExport = true 
    driverClassName = "org.postgresql.Driver" 
    username = "postgres" 
    password = "xxx" 

ビルドコンフィグ

dependencies { 
     // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes e.g. 
     // runtime 'mysql:mysql-connector-java:5.1.29' 
     // runtime 'org.postgresql:postgresql:9.3-1101-jdbc41' 
     runtime "org.postgresql:postgresql:9.4.1208.jre7" 
     test "org.grails:grails-datastore-test-support:1.0.2-grails-2.4" 
    } 

変更あなたのデシベルnumbeのpsqlのバージョンに応じてJRE番号。 私は助けてくれることを願っています。乾杯!

0

IntelliJで実行する代わりに、grails run-appを使用してGrailsアプリケーションを実行します。私はこれを持っていたissue too with MySQL

私はまだIntelliJで正しく動作するようにはなっていませんが、少なくともGrailsコンソールを使用すると機能します。

注:これは、すでにJDBCドライバが正しく設定されていることを前提としています。私はMySQL用に適切に設定していましたが、何とか間違って設定してしまったと思っていました。

0

答えがわかりませんが、application.ymlを使ってデータソース設定にアクセスできず、代わりにH2ドライバが使用されていることがわかりました。

build.gradle(ブロックのみを依存関係):

compile "org.springframework.boot:spring-boot-starter-logging" 
compile "org.springframework.boot:spring-boot-autoconfigure" 
compile "org.grails:grails-core" 
compile "org.springframework.boot:spring-boot-starter-actuator" 
compile "org.springframework.boot:spring-boot-starter-tomcat" 
compile "org.grails:grails-dependencies" 
compile "org.grails:grails-web-boot" 
compile "org.grails.plugins:cache" 
compile "org.grails.plugins:scaffolding" 
compile "org.grails.plugins:hibernate4" 
compile "org.hibernate:hibernate-ehcache" 

runtime "postgresql:postgresql:9.4.1208-atlassian-hosted" 

compile "org.grails.plugins:spring-security-core:3.0.4" 

console "org.grails:grails-console" 
profile "org.grails.profiles:web:3.1.6" 
runtime "com.bertramlabs.plugins:asset-pipeline-grails:2.8.2" 

testCompile "org.grails:grails-plugin-testing" 
testCompile "org.grails.plugins:geb" 
testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1" 
testRuntime "net.sourceforge.htmlunit:htmlunit:2.18" 

がapplication.ymlからデータベースに関連するすべてのものを消去され、代わりにapplication.groovyを使用:

dataSource{ 
    pooled= true 
    jmxExport=true 
    driverClassName= 'org.postgresql.Driver' 
    username= 'xxxx' 
    password= 'xxxx' } 

environments{ 
    development{ 
     dataSource{ 
      dbCreate= 'create-drop' 
      url= "jdbc:postgresql://localhost:5432/xxx" 
      logSql= true 
      hibernate.default_schema= "template_dm" 
     } 
    } 
    test{ 
     dataSource{ 
      dbCreate= 'create-drop' 
      url= "jdbc:postgresql://localhost:5432/xxx" 
      logSql= true 
      hibernate.default_schema= "template_dm" 
     } 
    } 
    production{ 
     dataSource{ 
      dbCreate= 'create-drop' 
      url= "jdbc:postgresql://localhost:5432/xxx" 
      logSql= true 
      hibernate.default_schema= "template_dm" 
     } 
    } 

} 

希望これはと皆を助け同じ問題。

乾杯

1

それはあなたの設定で不足しているタブを持っているように、データソースの後

dataSource: 
    pooled: true 
    jmxExport: true 
    driverClassName: org.postgresql.Driver 
    username: postgres 
    password: root 

すべてがインデントされる必要がありそうです。

関連する問題