涅槃ing
2016-01-24 20:23
@Autowired
private InjectionDAO injectionDAO;
//@Autowired
public InjectionServiceImpl(InjectionDAO injectionDAO) {
this.injectionDAO = injectionDAO;
}
//@Autowired
public void setInjectionDAO(InjectionDAO injectionDAO) {
this.injectionDAO = injectionDAO;
}
题主,解决了吗
解决了吗,我也遇到同样的问题了
应该是你的配置文件不对,没能识别@autowired注解
No default constructor found,你自己写了一个构造器,
public InjectionServiceImpl(InjectionDAO injectionDAO) {
this.injectionDAO = injectionDAO;
}
并且将注解注释掉了,java你自己谢了构造器他就不会生成默认的构造器,所以找不到了
@Autowired是对成员变量和函数,构造方法进行标注,完成自动装配,被你注释掉了
提示:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'injectionServiceImpl' defined in file [C:\Users\***\workspaceEE\springtest\bin\beanannotation\injection\service\InjectionServiceImpl.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [beanannotation.injection.service.InjectionServiceImpl]: No default constructor found; nested exception is java.lang.NoSuchMethodException: beanannotation.injection.service.InjectionServiceImpl.<init>()
Spring入门篇
268785 学习 · 963 问题
相似问题