深刻淺出springboot2.x(2)

經過掃描裝配bean 若是每一個bean都使用@Bean注入到IOC容器中的話,將是一件很麻煩的事。所以spring爲咱們提供了掃描裝配,使用的註解是@Component和@ComponentScan。 咱們能夠把上一章的代碼進行修改,首先在User中加入註解@Component和@Value。java @Component public class User { @Value("123"
相關文章
相關標籤/搜索