admin管理员组文章数量:1530272
最近在写ssm的时候遇见了一个这样的错误Bean named 'testImpl' must be of type [lcw.serviceimpl.testImpl], but was actually of type [com.sun.proxy.$Proxy13],在tomcat启动的时候就包了这个错误,找了好久终于发现了一个问题代码如下:
package lcw.controller;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import lcw.model.fload;
import lcw.service.testService;
import lcw.serviceimpl.testImpl;
@Controller
public class testController {
@Resource
private testImpl testImpl;
@RequestMapping("/addFload")
public void addFload(String fname){
fload fload = new fload();
fload.setfName(fname);
testImpl.addTest(fload);
}
}
在controller中 private testImpl testImpl;这个地方出现了问题testImpl 实现了一个接口,这个应用应该用接口来定义,改为如下即可:
package lcw.controller;
import javax.annotation.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import lcw.model.fload;
import lcw.service.testService;
import lcw.serviceimpl.testImpl;
@Controller
public class testController {
@Resource
private testService testImpl;
@RequestMapping("/addFload")
public void addFload(String fname){
fload fload = new fload();
fload.setfName(fname);
testImpl.addTest(fload);
}
}
错误就消失,既能运行。
本文标签: testImplnamedbeantypeSUN
版权声明:本文标题:Bean named 'testImpl' must be of type [lcw.serviceimpl.testImpl], but was actually of type [com.sun. 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/dianzi/1726603159a1077260.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论