1.Bean public class User { private int id; private String username; private String password; public String getPassword() { return password; } public void setPassword(String password) { this.password = password; } public String getUsername() { return
1.@Component:把普通pojo实例化到spring容器中,相当于配置文件中的<bean id="" class=""/> 2.@Autowired:Spring框架中进行对象注入 @Component public class Person { private String id; private String name; private String sex; //getter/setter省略 } @Service public class
参考博客原文地址: https://www.jb51.net/article/168398.htm https://www.cnblogs.com/mianteno/p/10692633.html http://www.pianshen.com/article/4112200143/ 1.构造器依赖循环 代码示例: @Component public class A { private B b; @Autowired public A(B b) { this.b=b; } } @Componen