Spring只将bean自动装配到使用@Resource,@ Autowired注释的字段/ setter /构造函数(不考虑Java Config和XML配置)。
有没有办法让Spring自动猜测可以放置@ Resource / @Autowired注释的位置,并根据它进行自动装配?
以下是它在Grails中的工作原理:
class BookController {
def bookService
…
}
如何让它在Spring中运行?
@Controller
public class BookController {
BookService bookService
…
}