1、@Service、@Controller、@Repository和@Component
@Service对应着业务层
@Controller对应着控制层
@Repository对应着持久层,这样将三者分别开来更加清晰
@Component对所有的类都可以使用
2、@Autowired和@Resource
@Resource注解的作用与@Autowired的作用相当,@Autowired是按照byType的方式自动注入,而@Resource默认是按byName注入的
1、@Service、@Controller、@Repository和@Component
@Service对应着业务层
@Controller对应着控制层
@Repository对应着持久层,这样将三者分别开来更加清晰
@Component对所有的类都可以使用
2、@Autowired和@Resource
@Resource注解的作用与@Autowired的作用相当,@Autowired是按照byType的方式自动注入,而@Resource默认是按byName注入的