Bean definition using Grails Spring DSL needs index/type/name arguments

505 Views Asked by At

In resources.groovy, I'm trying to define a bean named 'sql' which is a groovy.sql.Sql constructed using the dataSource defined by the application.

sql(groovy.sql.Sql, 'firstArgument', ref('dataSource') ) {}

Unfortunately this fails as follows --

Error executing script Console: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sql': Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities).

I looked at http://grails.org/doc/1.3.x/guide/14.%20Grails%20and%20Spring but there is no further information about legal syntax for specifying arguments to avoid type ambiguities beyond the example given there which uses "firstArgument".

I have tried passing "dataSource" and "javax.sql.DataSource" instead of "firstArgument", both unquoted and in double quotes but no success.

1

There are 1 best solutions below

0
On

The example given in the grails documentation is misleading you. They are constructing an instance of a class with two arguments; the first being a string and the second an int. You will want something like:

sql(groovy.sql.Sql, ref('dataSource') ) {}