@Bean是將組件注冊到Bean,讓IOC容器知道這個組件存在。
@AutoWired是組件和組件相互調用的時候,自動從ioc中取出來需要用的組件。比如Service,Controller,Dao的關系,這三個組件都分別加上了注冊的注解:@Service,@Controller,@Component,ioc中已經有了注冊信息,但是Service要用到Dao操作數據,所以在Service中的Dao頭上就要用@Autowired來給Dao自動賦值,來供Service用,同理,Controller中也要用到Service,那么就要在Service上邊加上@Autowired
