从非Spring类扩展Spring类

时间:2017-08-04 05:14:42

标签: spring spring-mvc

我需要编写Spring Component Bean,并且需要从常规类(来自abc.jar)扩展。

@Component
public DefClass extends AbcClass{
..
}

这是抛出错误AbcClass是一个非Spring类,不知道如何创建它作为SpringBean。 我试着在我的application-Context.xml中定义

<bean id ="abcBean" class ="package.AbcClass" "/>
        <bean id ="defClass"  class ="package.defClass" parent="abcBean"/> 

WEB-INF/classes/applicationCotext.xml]: Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: com.tivoli.pd.jutil.PDException
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1105) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1050) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.4.RELEASE.jar:4.2.4.RELEASE]

1 个答案:

答案 0 :(得分:0)

这不是春季项目。该类不可用(猜测abc.jar未添加到类路径中)。检查如何构建应用程序,检查abc.jar是否存在并包含在类路径中。