-
Notifications
You must be signed in to change notification settings - Fork 132
1:Bean
gris.wang edited this page Nov 8, 2017
·
1 revision
对象可以通过Bean注解进行管理,并可以通过Autowired注解实现对象的自动注入,避免了重复创建对象的烦恼,使用上和Spring保持一致,学习成本非常低。
@Bean(name="userService") // 如果不指定name,则使用类名作为bean的名称
public class UserServiceImpl implements IUserService{
}
@Bean() // 如果需要使用Autowired,则该类自身需要使用Bean注解标注
@RouterController(path="/UserController")
public class UserController {
@Autowired(name="userService")
private IUserService userService;
}