2016-01-15 13 views
5

IDE olarak IntelliJ IDEA 15.0.2 kullanıyorum. Bir Grails 3.0 uygulaması oluşturdum ve PostgreSQL'i yapılandırmak için biraz değiştirdim. PostgreSQL'i Grails 3.0 ile nasıl yapılandırabilirim?

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 

Ve benim build.gradle yılında

Ben runtime "postgresql:postgresql:9.4-1207.jdbc4" ekledi:

İşte benim dataSource olduğunu.

Ama çalıştırdığınızda o hataları verir:

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

Ne kaçırdım?

+1

Eğer üzerinde sınıf postgresql JDBC sürücüsünü var mı? –

+0

Lütfen bir cevabı kabul edin. –

cevap

4

Veri kaynağı

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

Yapı Yapılandırma

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" 
    } 

değiştirin db numbe psql'in sürümüne göre jre numarası. Umarım yardımcı oldum. Şerefe! Eğer veri kaynağı girintili gereken sonra bir sekme yapılandırmalarınızda

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

her şey eksik var gibi

0

IntelliJ aracılığıyla çalıştırmak yerine grails run-app kullanarak Grails uygulamasını çalıştırın. Bu issue too with MySQL vardı.

IntelliJ aracılığıyla düzgün çalışmaya nasıl başlayacağınızı henüz anlamadım, ancak en azından Grails konsolunu kullandığınızda çalışıyor!

Not: Bu, JDBC sürücüsünün doğru şekilde ayarlanmış olduğunu varsayıyordur. MySQL için düzgün bir şekilde ayarlamıştım ve bir şekilde yanlış yerleştirdiğimi düşünerek etrafta kazmaya devam ettim. o cevap ama kullanarak application.yml bana veri kaynağı yapılandırmasına erişim vermiyordu tespit edilmiştir eğer bilmiyorum

0

bunun yerine H2 Sürücü üstlendi.

build.gradle (sadece bağımlılıkları bloğu):

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" 

Silinmiş herşey application.yml gelen veritabanına bağlı ve yerine application.groovy kullanılan :

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" 
     } 
    } 

} 

Umut bununla herkese yardım aynı sorun.

Alkış

1

görünüyor.