由Grails生成的war文件会忽略数据源URL [英] war file generated by Grails ignores dataSource URL

查看:104
本文介绍了由Grails生成的war文件会忽略数据源URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Grails版本:1.1



Tomcat版本:5.5

问题:
应用程序不使用URL数据源。


看来,它正在使用其他一些数据源,但它似乎并不在内存DB中,因为我可以看到数据在会话之间保持不变。 / p>

我甚至尝试给出一个不存在的数据库名称 - 并且应用程序工作正常。我的意思是,我能够坚持数据,并在应用程序中获取数据
我无法确定数据在哪里持续存在!!!



我使用command-grails war生成了war文件

这就是dataSource配置的样子

  dataSource {

pooled = true

driverClassName =com.mysql.jdbc.Driver

username =user

password =pwd

}

hibernate {

cache.use_second_level_cache = true

cache.use_query_cache = true

cache.provider_class ='com.opensymphony.oscache.hibernate.OSCacheProvider'

}

环境{

生产{

dataSource {

dbCreate =创建

url = jdbc:mysql:// localhost:3307 / mydb?autoReconnect = true

dialect = org.hibernate.dialect.MySQL5Di alect

}

}

}


$ p>
development {

dataSource {

dbCreate =create

url =jdbc :mysql:// localhost:3307 / mydb?autoReconnect = true

dialect = org.hibernate.dialect.MySQL5Dialect
}
}

生产{

dataSource {

dbCreate =create
$ b $ url url =jdbc:mysql:// localhost:3307 / mydb?autoReconnect = true

dialect = org.hibernate.dialect.MySQL5Dialect
}
}


Grails version :1.1

Tomcat version: 5.5

The problem: The application doesn't use the URL data sources.

It seems like - it is using some other data source- but it doesn't seem to be in memory DB- since I can see the data persisted between sessions.

I have even tried giving a non -existant database name -and the application works fine. By that I mean that I am able to persist the data and fetch it fine- in the application I am unable to figure out where the data is getting persisted !!!

I generated the war file using the command- grails war

This is how the dataSource config looks like

 dataSource {

    pooled = true

    driverClassName = "com.mysql.jdbc.Driver"

    username = "user"

    password = "pwd"

 }

 hibernate {

    cache.use_second_level_cache=true

    cache.use_query_cache=true

    cache.provider_class='com.opensymphony.oscache.hibernate.OSCacheProvider'

 }

 environments {

    production {

        dataSource {

            dbCreate = "create" 

            url = "jdbc:mysql://localhost:3307/mydb?autoReconnect=true"

            dialect = org.hibernate.dialect.MySQL5Dialect

        }

    }

 }  

解决方案

You need to set a production data source since that's what grails uses when generating a war.


development {

        dataSource {

                dbCreate = "create" 

                url = "jdbc:mysql://localhost:3307/mydb?autoReconnect=true"

                dialect = org.hibernate.dialect.MySQL5Dialect
}
        }

production {

        dataSource {

                dbCreate = "create" 

                url = "jdbc:mysql://localhost:3307/mydb?autoReconnect=true"

                dialect = org.hibernate.dialect.MySQL5Dialect
}
        }

这篇关于由Grails生成的war文件会忽略数据源URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆