深刻浅出springboot2.x(2)

经过扫描装配bean 若是每一个bean都使用@Bean注入到IOC容器中的话,将是一件很麻烦的事。所以spring为咱们提供了扫描装配,使用的注解是@Component和@ComponentScan。 咱们能够把上一章的代码进行修改,首先在User中加入注解@Component和@Value。java @Component public class User { @Value("123"
相关文章
相关标签/搜索