html
grails [ .gsp ]
<%--
stmt 1
stmt 2
---
--%>
grails [ .groovy ]
// stmt1
or
/*
stmt1
stmt2
*/
grails [ .gsp ]
<%--
stmt 1
stmt 2
---
--%>
grails [ .groovy ]
// stmt1
or
/*
stmt1
stmt2
*/
grails-app/conf/spring/resources.groovy
which uses the Grails Spring DSL. Beans are defined inside a beans
property (a Closure):beans = {
// beans here
}
import my.company.MyBeanImplbeans = { myBean(MyBeanImpl) { someProperty = 42 otherProperty = "blue" } }
BootStrap.groovy
and integration tests) by declaring a public field whose name is your bean's name (in this case myBean
):class ExampleController {def myBean … }
Referencing Existing Beans
Beans declared inresources.groovy
orresources.xml
can reference other beans by convention. For example if you had aBookService
class its Spring bean name would bebookService
, so your bean would reference it like this in the DSL:beans = { productUtility ( ProductUtility ) {
someProperty = 42 otherProperty = "blue"
springSecurityService = ref ( "springSecurityService" ) } }
or like this in XML:
"myBean" class="my.company.MyBeanImpl">
"someProperty" value="42" />"otherProperty" value="blue" />
package my.companyclass MyBeanImpl { Integer someProperty String otherPropertySpringSecurityService springSecurityService or def springSecurityService }