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 personService{ @Autowired Person person; //方法省略 }
时间: 2024-10-29 03:30:25