1.加上Context命名空间

xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation
加上

http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"

2.要使用注解方式,进行依赖注入。要加上@Resource等注解的解析器

<context:annotation-config/>

3.要使用自动扫描,必须加入

<context:component-scan base-package="com.service"/>

该便签包含了<context:annotation-config/> 的功能。

4.自动扫描的四种方式

@Component @Service @Controller @Respository

 

 

 

 

相关文章:

  • 2022-01-03
  • 2020-06-08
  • 2022-12-23
  • 2022-01-01
  • 2021-02-28
  • 2021-07-03
  • 2021-06-28
猜你喜欢
  • 2021-11-11
  • 2021-09-29
  • 2021-11-26
  • 2022-12-23
  • 2022-02-07
  • 2021-05-24
  • 2020-05-04
相关资源
相似解决方案