How to access to a property defined in messages.properties file?

For reading property files in Groovy you can use the utility class ConfigSlurper and access the contained properties using GPath expressions. However, you have to be aware that ConfigSlurper doesn’t support standard Java property files. Normally the ConfigSlurper will be used to read .groovy files that may be similar to a property file, but adhere … Read more

How do I get at the goodies in my Grails Config.groovy at runtime?

In more recent versions of grails ConfigurationHolder has been deprecated. Instead you should use the grailsApplication object. grailsApplication.config.grails.serverURL If in a Controller or Service then use dependency injection of grailsApplication object. e.g. class MyController{ def grailsApplication def myAction() { grailsApplication.config.grails.serverURL } See How to access Grails configuration in Grails 2.0?

what does >> and 1* means in this groovy statement?

This is not groovy per se, but the testing framework called Spock (which is very popular among Groovy developers, for good reasons 🙂 – http://spockframework.github.io/spock/docs/1.0/index.html This expression in particular is a way to instruct Spock that it should expect exactly one call to the method prova in myService, and that this call should be mocked … Read more

Correct way to keep pooled connections alive (or time them out and get fresh ones) during longer inactivity for MySQL, Grails 2 app

The easiest is to configure the connection pool to specify the query to be run to test the connection before it is passed to the application: validationQuery=”select 1 as dbcp_connection_test” testOnBorrow=true This same “connection validation” query can be run on other events. I’m not sure of the defaults for these: testOnReturn=true testWhileIdle=true There are also … Read more

Externalizing Grails Datasource configuration

You can use a properties file specified in the grails.config.locations as a way to externalize the datasource configuration. Below is how I typically set up a Grails project: In my DataSource.groovy I specify this for the production environment: …. …. production { dataSource { dbCreate = “update” driverClassName = “com.myorg.jdbcDriverNotExists” url = “” username = … Read more

grails test-app to output to console

Add the -echoOut switch to grails test-app, this is new in the 1.2 release: grails test-app -echoOut There are a number of other useful switches on test-app as well, including: echo System.err messages: grails test-app -echoErr force a clean before running tests (without doing grails clean && grails test-app): grails test-app -clean only run unit … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)