No bean named 'injectionServiceImpl' available
InjectionServiceImp:
@Service
public class InjectionServiceImpl implements InjectionService {
@Autowired
private InjectionDAO injectionDAO;
public void save(String arg) {
System.out.println("service接收参数:"+arg);
arg=arg+""+this.hashCode();
injectionDAO.save(arg);
}
InjectionDAOImpl:
@Repository
public class InjtctionDAOImpl implements InjectionDAO {
public void save(String arg) {
System.out.println("保存数据"+arg);
}
}
Test:
public class Test {
public static void main(String[] args) {
ClassPathXmlApplicationContext ctx=new ClassPathXmlApplicationContext("spring-inject.xml");
InjectionService service=(InjectionService)ctx.getBean("injectionServiceImpl");
service.save("这是要保存的数据");
}
这样还是会找不到bean怎么回事?