1.可以被自動發現並註冊的類的條件:
加了@Component 、@Repository、@Service、@Controller這四個註解或者自定義的繼承自@Component的註解的類
@Component是一個通用的註解
@Repositroy用於註解Dao層
@Service 用於註解Service層
@Controller 用於註解Controller層
2.<context: component-scan base-package="包名" />
1.可以被自動發現並註冊的類的條件:
加了@Component 、@Repository、@Service、@Controller這四個註解或者自定義的繼承自@Component的註解的類
@Component是一個通用的註解
@Repositroy用於註解Dao層
@Service 用於註解Service層
@Controller 用於註解Controller層
2.<context: component-scan base-package="包名" />