开发者

Grails: how to configure a tomcat datasource?

开发者 https://www.devze.com 2023-03-11 04:04 出处:网络
I need to configure a datasource to use in grails. I created file scripts/_Events.groovy wi开发者_StackOverflow中文版th content bellow:

I need to configure a datasource to use in grails.

I created file scripts/_Events.groovy wi开发者_StackOverflow中文版th content bellow:

eventConfigureTomcat = {tomcat ->
    print "Applying changes to tomcat configuration..."
}

The question is: how can I use tomcat instance to configure a datasource in deployment time?

Note1: if there's a solution using something like server.xml file, it's great too.

Note2: tomcat object is a instance of org.apache.catalina.startup.Tomcat

Tks.


I assume you don't want to hard-code your production datasource. You can use Grails externalized configuration capability or a JNDI datasource defined in your deployed Tomcat context.


Solved! I putted this in config.groovy:

    grails.naming.entries = [
        'myDS': [
            type: "javax.sql.DataSource",
            auth: "Container",
            driverClassName: "foo.myDriver",
            maxActive: "8",
            maxIdle: "4",
            url: "my_jdbc_url",
            username: "user",
            password: "pass"
        ]
    ]

See also.

0

精彩评论

暂无评论...
验证码 换一张
取 消