Reputation: 37
What's the difference of different way to inject dependence in grails:
def abcService
@Autowired ABCService ABCService
Upvotes: 2
Views: 61
Reputation: 35961
abcService
(or other Spring bean with such name) will have different class
, then you'll get ClassCastException
hereabcService
NoSuchBeanDefinitionException
(previous two will get null
if it doesn't exists) @Autowired
could be combined with def
type alsoBasically Grails services are standard Spring beans, Grails just follows convention over configuration
that for every class in services
dir it will create a bean with name abcService
that could be autowired into other beans. All other job is done by Spring. See also docs for Spring and Grails
Upvotes: 2