spring版本3.0.5
@Component
public class IndexFacade {
@Autowired
private UserService userService;
其中 userService访问时是null
注解扫描的包
<context:component-scan base-package="org.yanb.test" use-default-filters="false">
<context:include-filter type="regex" expression="org.test.main.control.*Control"/>
<context:include-filter type="regex" expression="org.test.main.facade.*Facade"/>
<context:include-filter type="regex" expression="org.test.main.service.*Service"/>
<context:include-filter type="regex" expression="org.test.main.dao.impl.*Impl"/>
<!--不扫描<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> -->
</context:component-scan>
奇怪的是control可以注入进来userService
@Controller
public class IndexControl extends BaseController {
@Autowired
private IndexFacade indexFacade;
@Autowired
private UserService userService;
求大神帮解决下吧谢谢,我没分了抱歉