SpringBoot-注解系列-@inject

CDI(Contexts and Dependency Injection 上下文依赖注入),是JAVA官方提供的依赖注入实现,可用于Dynamic Web Module中,先给3篇老外的文章,写得很不错

1、Java EE CDI Dependency Injection (@Inject) tutorial
2、Java EE CDI Producer methods tutorial
3、Java EE CDI bean scopes

1、属性注入

    public class IndexController {
        @Inject
        @Book
        private ProductService bookProductService;
    }

2、 Method(方法)注入

3、 Constructor(构造器)注入

猜你喜欢

转载自blog.csdn.net/weixin_42299369/article/details/82283886