从零实现MVC框架之依赖注入IOC(7)
发布时间:2020-12-13 22:48:26 所属栏目:百科 来源:网络整理
导读:我们的目的是在学习MVC的实现方式,而不是真的做一个MVC框架,所以就一切从简,所以这里我们只做Controller中的依赖注入。 也就是说只有Controller中才可以使用我们下面创建的Inject注解。如果再其他的地方使用是注入不成功的哦。 注解 package com.hc.annot
我们的目的是在学习MVC的实现方式,而不是真的做一个MVC框架,所以就一切从简,所以这里我们只做Controller中的依赖注入。 也就是说只有Controller中才可以使用我们下面创建的Inject注解。如果再其他的地方使用是注入不成功的哦。 注解package com.hc.annotation; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; /** * * @author chuer * @date 2014-7-16 下午4:34:14 * @version V1.0 */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface Inject { public String className(); }
|