2016-12-02 93 views
0

我想用Intellij IDEA運行Grails 3應用程序,但我不知道如何連接到oracle數據庫,並且應該在哪裏放置oracle jdbc驅動程序? 這是我在application.yml代碼 --- 休眠: 緩存: 查詢:假 use_second_level_cache:真 use_query_cache:假 region.factory_class:「org.hibernate.cache.ehcache。 EhCacheRegionFactory」如何使用Intellij IDEA連接到Grails 3項目中的Oracle數據庫?

dataSource: 
    pooled: true 
    jmxExport: true 
    driverClassName: oracle.jdbc.driver.OracleDriver 
    username: "wy" 
    password: "19901110" 

environments: 
    development: 
     dataSource: 
      dbCreate: update 
      url: jdbc:oracle:thin:@//localhost:1521/DBW 
    test: 
     dataSource: 
      dbCreate: update 
      url: jdbc:oracle:thin:@//localhost:1521/DBW 
    production: 
     dataSource: 
      dbCreate: update 
      url: jdbc:oracle:thin:@//localhost:1521/DBW 
      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 

--- 
--- 
grails: 
    profile: web 
    codegen: 
     defaultPackage: keepup 
    spring: 
     transactionManagement: 
      proxies: false 
info: 
    app: 
     name: '@[email protected]' 
     version: '@[email protected]' 
     grailsVersion: '@[email protected]' 
spring: 

    groovy: 
     template: 
      check-template-location: false 

--- 
grails: 
    mime: 
     disable: 
      accept: 
       header: 
        userAgents: 
         - Gecko 
         - WebKit 
         - Presto 
         - Trident 
     types: 
      all: '*/*' 
      atom: application/atom+xml 
      css: text/css 
      csv: text/csv 
      form: application/x-www-form-urlencoded 
      html: 
       - text/html 
       - application/xhtml+xml 
      js: text/javascript 
      json: 
       - application/json 
       - text/json 
      multipartForm: multipart/form-data 
      pdf: application/pdf 
      rss: application/rss+xml 
      text: text/plain 
      hal: 
       - application/hal+json 
       - application/hal+xml 
      xml: 
       - text/xml 
       - application/xml 
    urlmapping: 
     cache: 
      maxsize: 1000 
    controllers: 
     defaultScope: singleton 
    converters: 
     encoding: UTF-8 
    views: 
     default: 
      codec: html 
     gsp: 
      encoding: UTF-8 
      htmlcodec: xml 
      codecs: 
       expression: html 
       scriptlets: html 
       taglib: none 
       staticparts: none 
endpoints: 
    jmx: 
     unique-names: true 

,我把JDBC驅動程序到這裏: jdbc driver

希望有人能解決我的問題

非常感謝你!

+0

你是不是能夠得到司機作爲一個正常的依賴?在這方面我不熟悉Oracle。如果沒有,這是一個重複http://stackoverflow.com/questions/32339950/how-to-add-a-non-mavenized-jar-dependency-to-a-grails-project-grails-3-x – rmlan

+0

此外,這個問題與Intellij無關,因爲這個問題超出了在IDEA中運行它的範圍。 – rmlan

回答

0

爲了讓您的應用程序使用Oracle作爲數據庫,您必須將JAR文件甲骨文jdbc驅動的加入到lib文件夾,你的項目目錄內。 這可以通過將驅動程序文件簡單地複製到Lib文件夾來完成。 之後,只需修改您的Application.yml文件。

+0

我已經將Oralce驅動程序的jar文件添加到我的Lib文件夾(由我自己創建) ,並將以下行添加到./build.gradle,「dependencies」部分: 'runtime「com.oracle:ojdbc14:10.2。 0.3.0「' –

+0

但它似乎不工作,有什麼細節丟失? –

0

放入[JAVA_HOME]/JRE/lib/ext目錄的Oracle罐子假設你正在使用JDK

相關問題