java - 如何使用Intellij IDEA在Grails 3项目中连接到Oracle数据库?

标签 java grails jdbc intellij-idea grails-3.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'

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: '@info.app.name@'
        version: '@info.app.version@'
        grailsVersion: '@info.app.grailsVersion@'
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

希望有人可以解决我的问题

非常感谢!!!

最佳答案

为了允许您的应用程序将Oracle用作数据库,您必须将的Oracle jdbc驱动程序 jar 文件添加到项目目录内的Lib文件夹中。
只需将驱动程序文件复制到Lib文件夹中即可完成。
之后,只需修改您的 Application.yml 文件。

关于java - 如何使用Intellij IDEA在Grails 3项目中连接到Oracle数据库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40934919/

相关文章:

java - 是否可以更改 SWT 中文本小部件的提示文本的颜色?

java - java中的FileNotFoundException

grails - Grails将1.3.7升级到2.4.4-在对部分代码进行细微更改后重新编译整个项目

java - 使 JDBC 插入查询更快

java - 无法将类型 [org.apache.tomcat.jdbc.pool.DataSource] 的构造函数参数值转换为所需类型 [java.lang.String] :

java - 为什么人们在事件队列上运行 Java GUI

java - Java中的欧拉程序

grails - 如何从g:select标记传递值

grails - 如果子字符串匹配,则在“字符串”字段中插入链接

Mysql简单查询报错