Grails: Getting the Data Source in a normal groovy class
问题 How can I get access to the data source from within a normal groovy class? Injection doesn't work like it does with services. The reason for this is that I need to do some manual database calls (ie: SQL statements using the groovy.sql.Sql class) from the groovy class since I'm working with a legacy database. 回答1: dataSource is a bean which gets auto injected in services when used. All beans are auto wired in grails artifacts (controllers, services etc) by default. In your case you are using a