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