ApplicationContext factory=new ClassPathXmlApplicationContext("classpath:applicationContext.xml");? String[] s = factory.getBeanDefinitionNames(); for(String ss:s){ System.out.println(ss); }userServiceImpluserControlleruserDaoImplorg.springframework.context.annotation.internalConfigurationAnnotationProcessororg.springframework.context.annotation.internalAutowiredAnnotationProcessororg.springframework.context.annotation.internalRequiredAnnotationProcessororg.springframework.context.annotation.internalCommonAnnotationProcessororg.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor#0org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessororg.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor @Autowired private IUserService userService; public void say(){ userService.say(); }
1 回答
已采納

chinesszz
TA貢獻(xiàn)12條經(jīng)驗(yàn) 獲得超5個(gè)贊
@Autowired是按類型
@Resource是根據(jù)名字,你看是不是你有重復(fù)的類,或者是名字不是首字母小寫,
添加回答
舉報(bào)
0/150
提交
取消