我在模型中使用了第三方库类XYZ作为参数。 XYZ没有默认的构造函数。所以春天是不能够创建豆给它的错误信息为春天的bean类实例化没有默认构造函数的类
org.springframework.web.util.NestedServletException: Request processing failed;
nested exception is org.springframework.data.mapping.model.MappingInstantiationException:
Could not instantiate bean class [org.abc.def.XYZ]: No default constructor found;nested exception is java.lang.NoSuchMethodException: org.abc.def.XYZ./<init/>()
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:681)
我该怎么做才能解决这个问题?我无法将默认构造函数添加到XYZ。
我在我的调度程序servlet中添加了以下内容,但它仍然无效。
<bean name="token" class="org.abs.def.Xyx">
<constructor-arg name="arg1" value="val1"/>
<constructor-arg name="arg2" value="val2"/>
<constructor-arg name="arg3" value="val3"/>
</bean>
谢谢。
我试过这样做,但它不起作用。它抛出相同的错误! – shailesh
你在哪里以及如何添加它?你如何初始化你的春天的上下文?你使用的是什么版本的春天? – fmucar