将spring从3.1.1升级到4.3.3之后的Spring UnsatisfiedDependencyException(Spring UnsatisfiedDependencyException

编程入门 行业动态 更新时间:2024-10-28 16:27:51
将spring从3.1.1升级到4.3.3之后的Spring UnsatisfiedDependencyException(Spring UnsatisfiedDependencyException after upgrading spring from 3.1.1 to 4.3.3)

我正在尝试将我的应用程序升级到最新版本的Spring&Camel,但我得到了下面列出的例外情况。 我还列出了spring遇到问题的配置部分。 仅供参考,我的应用程序(包括此配置元素)可以与旧版本的库一起使用。 为什么弹簧4.3.3不能在Spring 3.1.1找到该类时发现它没有任何问题?

这些是我正在更新的库:

春季3.1.1至4.3.3 骆驼2.13.4至2.17.3 cglib 2.2.2至3.2.4 cxf 2.6.1至3.1.7

我真的只更改了pom.xml和由于库更新导致的一些小的更改。 任何人都可以指出我正确的方向如何解决这个问题?

Spring在这里有一个问题

<bean id="test.format" class="org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat"> <constructor-arg value="com.application.businessobject.test" /> </bean>

例外

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'test.format' defined in class path resource [trs.application.finance.businessactivities.watchers.externaldata.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]: Failed to convert value of type [java.lang.String] to required type [java.lang.Class]; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.application.businessobject.test]

I'm trying to upgrade my application to the latest version of Spring & Camel, but I'm getting the exception listed below. I also listed the config section that spring is having an issue with. FYI, my application, including this config element, is working fine with the older versions of the libraries. Why can't spring 4.3.3 find that class when Spring 3.1.1 finds it without any issues?

These are the libraries I'm updating:

Spring 3.1.1 to 4.3.3 Camel 2.13.4 to 2.17.3 cglib 2.2.2 to 3.2.4 cxf 2.6.1 to 3.1.7

I really only changed the pom.xml & a couple minor changes due to the library updates. Can anyone point me in the right direction on how to resolve this?

Spring is having an issue here

<bean id="test.format" class="org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat"> <constructor-arg value="com.application.businessobject.test" /> </bean>

Exception

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'test.format' defined in class path resource [trs.application.finance.businessactivities.watchers.externaldata.xml]: Unsatisfied dependency expressed through constructor parameter 0: Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]: Failed to convert value of type [java.lang.String] to required type [java.lang.Class]; nested exception is java.lang.IllegalArgumentException: Cannot find class [com.application.businessobject.test]

最满意答案

https://github.com/apache/camel/blob/master/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java

显然在早期的CAMEL版本中有一个这个类的构造函数,它期望包作为String ... vararg参数,但是从那时起就被删除了

https://github.com/apache/camel/commit/ce6bf6e6feb5f425cd544c4c1edfa2eb34641907

因此,您的bean声明不再有效,并导致上述异常

Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]:

应该声明

<bean id="test.format" class="org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat"> <constructor-arg> <value type="java.lang.Class">com.application.businessobject.Test</value> </constructor-arg> </bean>

https://github.com/apache/camel/blob/master/components/camel-bindy/src/main/java/org/apache/camel/dataformat/bindy/fixed/BindyFixedLengthDataFormat.java

Apparently in earlier CAMEL versions there was a constructor of this class that expected packages as a String... vararg parameter, but has been since removed with this commit

https://github.com/apache/camel/commit/ce6bf6e6feb5f425cd544c4c1edfa2eb34641907

So your bean declaration is not valid any more and results in the above exception

Could not convert argument value of type [java.lang.String] to required type [java.lang.Class]:

Should be declared instead

<bean id="test.format" class="org.apache.camel.dataformat.bindy.fixed.BindyFixedLengthDataFormat"> <constructor-arg> <value type="java.lang.Class">com.application.businessobject.Test</value> </constructor-arg> </bean>

更多推荐

本文发布于:2023-08-04 14:02:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1416495.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:升级到   spring   upgrading   UnsatisfiedDependencyException   Spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!