chenweichu
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;
 //方法省略
}

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2022-01-01
  • 2022-01-01
  • 2022-01-01
  • 2021-11-19
  • 2021-10-06
  • 2022-01-01
  • 2022-01-01
猜你喜欢
  • 2022-01-01
  • 2022-01-01
  • 2022-01-01
  • 2021-09-07
  • 2021-10-21
  • 2021-03-31
  • 2021-10-29
相关资源
相似解决方案