“Bean named XXX must be of type[XXX], but was actually of type[XXX]”

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/dingchenxixi/article/details/48320721

</pre>在进行注入的时候没有使用接口 ,而是直接使用的实现类,所以出现了错误<p></p><p>例如:</p><p> </p><pre name="code" class="java">  应该使用 private IGroupService groupService; 进行注入,
而我使用的是  private GroupService groupService;
GroupService是IGroupService的一个实现类


引用:

在spring中@Transaction是通过AOP实现的,而spring对AOP有两种实现方式,一种是动态代理,它是通过接口方式实现的,要求所代理的类一定是实现了某一个接口,对一般的类就无法代理,spring默认是这种;通过设置proxy-target-class="true",则是使用CGLIB实现AOP,CGLIB直接生成二进制码,使得普通类也可以实现AOP。在没有设置proxy-target-class="true"时,使用动态代理,是一个临时生成的类,如proxy17,它不是@Resource指定的类,因此出现了上述错误。

展开阅读全文

mybatis 报错 There is no getter for property named 'xxx' in 'xxx'

04-12

[code=text]Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'is_partner' in 'class com.xfj.base.bossapp.domain.SellerAgent'rn at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:333)rn at org.apache.ibatis.reflection.MetaClass.getGetInvoker(MetaClass.java:160)rn at org.apache.ibatis.reflection.wrapper.BeanWrapper.getBeanProperty(BeanWrapper.java:151)rn at org.apache.ibatis.reflection.wrapper.BeanWrapper.get(BeanWrapper.java:44)rn at org.apache.ibatis.reflection.MetaObject.getValue(MetaObject.java:123)rn at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextMap.get(DynamicContext.java:89)rn at org.apache.ibatis.builder.xml.dynamic.DynamicContext$ContextAccessor.getProperty(DynamicContext.java:107)rn at org.apache.ibatis.ognl.OgnlRuntime.getProperty(OgnlRuntime.java:1657)rn at org.apache.ibatis.ognl.ASTProperty.getValueBody(ASTProperty.java:92)rn at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)rn at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)rn at org.apache.ibatis.ognl.ASTNotEq.getValueBody(ASTNotEq.java:49)rn at org.apache.ibatis.ognl.SimpleNode.evaluateGetValueBody(SimpleNode.java:170)rn at org.apache.ibatis.ognl.SimpleNode.getValue(SimpleNode.java:210)rn at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:333)rn at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:413)rn at org.apache.ibatis.ognl.Ognl.getValue(Ognl.java:395)rn at org.apache.ibatis.builder.xml.dynamic.OgnlCache.getValue(OgnlCache.java:42)rn at org.apache.ibatis.builder.xml.dynamic.ExpressionEvaluator.evaluateBoolean(ExpressionEvaluator.java:32)rn at org.apache.ibatis.builder.xml.dynamic.IfSqlNode.apply(IfSqlNode.java:30)rn at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)rn at org.apache.ibatis.builder.xml.dynamic.TrimSqlNode.apply(TrimSqlNode.java:42)rn at org.apache.ibatis.builder.xml.dynamic.MixedSqlNode.apply(MixedSqlNode.java:29)rn at org.apache.ibatis.builder.xml.dynamic.DynamicSqlSource.getBoundSql(DynamicSqlSource.java:37)rn at org.apache.ibatis.mapping.MappedStatement.getBoundSql(MappedStatement.java:241)rn at org.apache.ibatis.executor.statement.BaseStatementHandler.(BaseStatementHandler.java:61)rn at org.apache.ibatis.executor.statement.PreparedStatementHandler.(PreparedStatementHandler.java:36)rn at org.apache.ibatis.executor.statement.RoutingStatementHandler.(RoutingStatementHandler.java:42)rn at org.apache.ibatis.session.Configuration.newStatementHandler(Configuration.java:348)rn at org.apache.ibatis.executor.SimpleExecutor.doUpdate(SimpleExecutor.java:43)rn at org.apache.ibatis.executor.BaseExecutor.update(BaseExecutor.java:108)rn at org.apache.ibatis.executor.CachingExecutor.update(CachingExecutor.java:75)rn at org.apache.ibatis.session.defaults.DefaultSqlSession.update(DefaultSqlSession.java:145)rn at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)rn at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)rn at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)rn at java.lang.reflect.Method.invoke(Method.java:606)rn at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:355)rn ... 176 more[/code]rnrn找了好久都找不到什么问题,用的方法是用工具生成的update方法 论坛

The method xxx of type new xxxx must override 的问题

11-22

The method isViewFromObject(View, Object) of type new PagerAdapter() must override or implement a supertype methodnn网上说的方法: 一、 n因为你的Compiler 是jdk1.5,只要把它改为 1.6n方法: n1. window ->preferences... -> java -> Compilern2. Compiler compliance level : 6.0n二、 把项目的JRE变成6.0的n项目右键->build path->configure build path->java Compiler(左边那排中) ->在右边的Compiler compliance level 修改版本为6.0 n 试过了没有作用。n n n nimport java.awt.Window;nimport java.util.ArrayList;nimport java.util.List;nnimport javax.swing.text.View;nnimport com.csst.videotalk.R;nimport android.app.Activity;nimport android.os.Bundle;nimport android.widget.ImageView;nimport android.widget.ImageView.ScaleType;nimport android.support.v4.view.PagerAdapter;nimport android.support.v4.view.ViewPager;nnnimport android.view.ViewGroup; npublic class ViewPaper_activity extends Activitynn ViewPager mViewPager; n private int[] mImgIds = new int[] /*R.drawable.guide_image1, n R.drawable.guide_image2, R.drawable.guide_image3 */; n private List mImageViews = new ArrayList(); n n @Override n protected void onCreate(Bundle savedInstanceState) n n super.onCreate(savedInstanceState); n n //requestWindowFeature(Window.FEATURE_NO_TITLE); n setContentView(R.layout.view_paper); n n initData(); n n mViewPager = (ViewPager) findViewById(R.id.id_viewpager); n n mViewPager.setAdapter(new PagerAdapter() n n @Override n public Object instantiateItem(ViewGroup container, int position) n n n container.addView(mImageViews.get(position)); n return mImageViews.get(position); n n n @Override n public void destroyItem(ViewGroup container, int position, n Object object) n n n container.removeView(mImageViews.get(position)); n n n @Override n //就是这里一直报错n public boolean isViewFromObject(View view, Object object) n n n return view == object; n n n @Override n public int getCount() n n return mImgIds.length; n n ); n n n n private void initData() n n for (int imgId : mImgIds) n n ImageView imageView = new ImageView(getApplicationContext()); n imageView.setScaleType(ScaleType.CENTER_CROP); n imageView.setImageResource(imgId); n mImageViews.add(imageView); n n n 问答

Xxx

10-20

C# 仿QQ截图程序 winformrnusing System;rnusing System.Collections.Generic;rnusing System.ComponentModel;rnusing System.Data;rnusing System.Drawing;rnusing System.Text;rnusing System.Windows.Forms;rnrnnamespace Clientrnrn public partial class Catch : Formrn rn public Catch()rn rn InitializeComponent();rn rnrn 用户变量#region 用户变量rn private Point DownPoint = Point.Empty;//记录鼠标按下坐标,用来确定绘图起点rn private bool CatchFinished = false;//用来表示是否截图完成rn private bool CatchStart = false;//表示截图开始rn private Bitmap originBmp;//用来保存原始图像rn private Rectangle CatchRect;//用来保存截图的矩形rn #endregionrnrn //窗体初始化操作rn private void Catch_Load(object sender, EventArgs e)rn rn this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);rn this.UpdateStyles();rn //以上两句是为了设置控件样式为双缓冲,这可以有效减少图片闪烁的问题,关于这个大家可以自己去搜索下rn originBmp = new Bitmap(this.BackgroundImage);//BackgroundImage为全屏图片,我们另用变量来保存全屏图片rn rnrn //鼠标右键点击结束截图rn private void Catch_MouseClick(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Right)rn rn this.DialogResult = DialogResult.OK;rn this.Close();rn rn rnrn //鼠标左键按下时动作rn private void Catch_MouseDown(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left)rn rn if (!CatchStart)rn //如果捕捉没有开始rn CatchStart = true;rn DownPoint = new Point(e.X, e.Y);//保存鼠标按下坐标rn rn rn rnrn private void Catch_MouseMove(object sender, MouseEventArgs e)rn rn if (CatchStart)rn //如果捕捉开始rn Bitmap destBmp = (Bitmap)originBmp.Clone();//新建一个图片对象,并让它与原始图片相同rn Point newPoint = new Point(DownPoint.X, DownPoint.Y);//获取鼠标的坐标rn Graphics g = Graphics.FromImage(destBmp);//在刚才新建的图片上新建一个画板rn Pen p = new Pen(Color.Blue,1);rn int width = Math.Abs(e.X - DownPoint.X), height = Math.Abs(e.Y - DownPoint.Y);//获取矩形的长和宽rn if (e.X < DownPoint.X)rn rn newPoint.X = e.X;rn rn if (e.Y < DownPoint.Y)rn rn newPoint.Y = e.Y;rn rn CatchRect = new Rectangle(newPoint,new Size(width,height));//保存矩形rn g.DrawRectangle(p,CatchRect);//将矩形画在这个画板上rn g.Dispose();//释放目前的这个画板rn p.Dispose();rn Graphics g1 = this.CreateGraphics();//重新新建一个Graphics类rn //如果之前那个画板不释放,而直接g=this.CreateGraphics()这样的话无法释放掉第一次创建的g,因为只是把地址转到新的g了.如同string一样rn g1 = this.CreateGraphics();//在整个全屏窗体上新建画板rn g1.DrawImage(destBmp,new Point(0,0));//将刚才所画的图片画到这个窗体上rn //这个也可以属于二次缓冲技术,如果直接将矩形画在窗体上,会造成图片抖动并且会有无数个矩形.rn g1.Dispose();rn destBmp.Dispose();//要及时释放,不然内存将会被大量消耗rn rn rn rnrn private void Catch_MouseUp(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left)rn rn if (CatchStart)rn rn CatchStart = false;rn CatchFinished = true;rn rn rn rn rnrn //鼠标双击事件,如果鼠标位于矩形内,则将矩形内的图片保存到剪贴板中rn private void Catch_MouseDoubleClick(object sender, MouseEventArgs e)rn rn if (e.Button == MouseButtons.Left&&CatchFinished)rn rn if (CatchRect.Contains(new Point(e.X, e.Y)))rn rn Bitmap CatchedBmp = new Bitmap(CatchRect.Width, CatchRect.Height);//新建一个于矩形等大的空白图片rn Graphics g = Graphics.FromImage(CatchedBmp);rn g.DrawImage(originBmp, new Rectangle(0, 0, CatchRect.Width, CatchRect.Height), CatchRect, GraphicsUnit.Pixel);rn //把orginBmp中的指定部分按照指定大小画在画板上rn Clipboard.SetImage(CatchedBmp);//将图片保存到剪贴板rn g.Dispose();rn CatchFinished = false;rn this.BackgroundImage = originBmp;rn CatchedBmp.Dispose();rn this.DialogResult = DialogResult.OK;rn this.Close();rn rn rn rn rnrn  C.创建了Catch窗体后,我们在截图按钮(位于聊天窗体上)上加入以下事件:rn private void bCatch_Click(object sender, EventArgs e)rn rnrn if (bCatch_HideCurrent.Checked)rn rn this.Hide();//隐藏当前窗体rn Thread.Sleep(50);//让线程睡眠一段时间,窗体消失需要一点时间rn Catch CatchForm = new Catch();rn Bitmap CatchBmp = new Bitmap(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height);//新建一个和屏幕大小相同的图片 rn Graphics g = Graphics.FromImage(CatchBmp);rn g.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(Screen.AllScreens[0].Bounds.Width, Screen.AllScreens[0].Bounds.Height));//保存全屏图片rn CatchForm.BackgroundImage = CatchBmp;//将Catch窗体的背景设为全屏时的图片rn if (CatchForm.ShowDialog() == DialogResult.OK)rn //如果Catch窗体结束,就将剪贴板中的图片放到信息发送框中rn IDataObject iData = Clipboard.GetDataObject();rn DataFormats.Format myFormat = DataFormats.GetFormat(DataFormats.Bitmap);rn if (iData.GetDataPresent(DataFormats.Bitmap))rn rn richtextbox1.Paste(myFormat);rn Clipboard.Clear();//清除剪贴板中的对象rn rn this.Show();//重新显示窗体rn rn rnrn rn 论坛

JSP XXX cannot be resolved to a type

03-13

代码1:rnpackage TT.vo;rnrnimport java.io.Serializable;rn@SuppressWarnings("serial")rnpublic class Dept implements Serializable rn private Integer deptno;rn private String dname;rn private String loc;rnpublic Integer getDeptno() rn return deptno;rnrnpublic void setDeptno(Integer deptno) rn this.deptno = deptno;rnrnpublic String getDname() rn return dname;rnrnpublic void setDname(String dname) rn this.dname = dname;rnrnpublic String getLoc() rn return loc;rnrnpublic void setLoc(String loc) rn this.loc = loc;rnrnrn@Overridern public String toString() rn // TODO Auto-generated method stubrn return "部门号:"+this.deptno+" 部门名:"+this.dname+" 所在地:"+this.loc;rn rnrn代码2:rn<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>rn<%@ page import="TT.factory.*" %>rn<%@ page import="TT.vo.*" %>rn<%rnString path = request.getContextPath();rnString basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";rnString url = basePath + "DeptProject/WebRoot/pages/back/admin/dept_insert.jsp";rnrn%>rn <%rn request.setCharacterEncoding("UTF-8");rn rn Dept vo = new Dept();rn vo.setDeptno(Integer.parseInt(request.getParameter("deptno")));rn vo.setDname(request.getParameter("dname"));rn vo.setLoc(request.getParameter("loc")); rn String msg = "部门数据增加失败";rn if(ServiceFactory.getIDeptServiceInstance().insert(vo))rn msg = "部门信息插入成功";rn rnrn %>rnrnrn在Tomcat上运行时,报错:rnorg.apache.jasper.JasperException: Unable to compile class for JSP: rnrnAn error occurred at line: 13 in the jsp file: /DeptProject/WebRoot/pages/back/admin/dept_insert_do.jsprnDept cannot be resolved to a typern10: <%rn11: request.setCharacterEncoding("UTF-8");rn12: rn13: Dept vo = new Dept();rn14: /* vo.setDeptno(Integer.parseInt(request.getParameter("deptno")));rn15: vo.setDname(request.getParameter("dname"));rn16: vo.setLoc(request.getParameter("loc")); */ 论坛

没有更多推荐了,返回首页