我已经调试了一段时间了,希望有人能在这里解决问题。
我有一个Maven项目添加到Jenkins中,使用JDK 1.6。我在这个项目中使用AOP来处理数据库事务。
当我在Jenkins中运行构建时,我的测试用例会失败,并显示以下异常:
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'dataHandlerClassificationImpl':
Injection of resource dependencies failed; nested exception is
org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'writerDataLocationImpl' must be of type [xxx.script.WriterData],
but was actually of type [$Proxy17]
...
...
Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException:
Bean named 'writerDataLocationImpl' must be of type [xxx.script.WriterData],
but was actually of type [$Proxy17]
...
...
DataHandlerClassificationImpl
类的代码大致如下:
@Service
public class DataHandlerClassificationImpl extends DataHandler {
@Resource(name="writerDataLocationImpl")
private WriterData writerData;
...
}
WriterData
是一个具有多个实现的接口。
我可以从IDE中执行代码而没有问题。为了确定它是Maven问题还是Jenkins问题,我使用命令行导航到Jenkins项目作业文件夹,并能够运行mvn test
而没有任何错误。
我知道代理错误与AOP有关,并且只能将自动装配应用于接口而不是具体类...但这里并非如此,因为我能够在Jenkins之外正常运行我的代码。
有什么想法吗?谢谢。
clean cobertura:cobertura site
。只是出于好奇心,我将其改为clean test
,而它也能正常工作。但当我把它改为clean site
时,我又遇到了同样的异常。看起来这与site
有关。有任何想法吗?谢谢。 - limcwriterData.getClass().getInterfaces
?Intellij基本上给了我一个常规的编译错误。 - limc<aop:config proxy-target-class="true">
确实解决了问题!非常感谢。如果您可以在下面发布您的最后一条评论作为答案,我会点赞并将其标记为已完成。再次感谢。 - limc