Spring 注解@Resource & @Autowired & @Service & @Component

组合1 @Resource+@Service:

    @Resource(name = "captchaService")
    private CaptchaService captchaService;
	@Service("captchaService")
	public class CaptchaServiceImpl implements CaptchaService {

组合2 @Autowired+@Service:

    @Autowired
    private CaptchaService captchaService;
	@Service("captchaService")
	public class CaptchaServiceImpl implements CaptchaService {

组合3 @Autowired+@Component:

    @Autowired
    private CaptchaService captchaService;
	@Component
	public class CaptchaServiceImpl implements CaptchaService {

猜你喜欢

转载自blog.csdn.net/dongzhensong/article/details/88104577