Spring @自动连线不';如果删除组件扫描,则无法工作

Spring @自动连线不';如果删除组件扫描,则无法工作,spring,autowired,explicit,Spring,Autowired,Explicit,我面临的问题是,如果我从配置中删除组件扫描标记,@Autowired注释不再有效(在所有使用此注释的Java类中) <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="ht

我面临的问题是,如果我从配置中删除组件扫描标记,@Autowired注释不再有效(在所有使用此注释的Java类中)

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

  <context:component-scan base-package="efco.auth" />

here are some beans...
此Bean在另一个spring配置文件中定义:

<bean id="BasketLogic" class="efco.logic.EfcoBasketLogic">
    <property name="documentLogic" ref="DocumentLogic" />
    <property name="stateAccess" ref="StateAccess" />
    <property name="contextAccess" ref="ContextAccess" />
  </bean>

如您所见,erpService没有定义。其他三个属性位于BasketLogicImpl上,并具有setter


我做错了什么?

autowire=“byType”
autowire=“byName”
添加到bean声明中应该可以完成这项工作。

正如Tomasz所说,您需要
才能让
@Autowired
工作。当您使用
时,它会隐式地为您包含
注释配置。

好的,
@Autowired
注释只有在您使用
时才会被选中。好的,如果我删除
并将autowire=“byType”添加到
并为现场服务添加一个setter,否则就不行了。奇怪的是,我认为(并阅读)如果使用自动布线,就不需要设置器。
<bean id="BasketLogic" class="efco.logic.EfcoBasketLogic">
    <property name="documentLogic" ref="DocumentLogic" />
    <property name="stateAccess" ref="StateAccess" />
    <property name="contextAccess" ref="ContextAccess" />
  </bean>