我正在eclpise中开发一个maven项目。首先,我制作了DAO图层,然后对其进行了验证 - 工作正常。但是当我将jar添加到我的项目中时(对于其他层(商务)),DAO层无法按预期工作。
当我添加这个jar时发生错误:[func_frwmwk_clt,func_frwmwk_cmn,func_frwmwk_srv, func_util, ott_utilities, soi, toplink ]
但是如果我删除它,项目就可以运行并给出一个真实的结果。我该如何解决这个问题?
主要课程:
package com.services;
import com.entity.Ws_security;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.services.Interface_ws_security_services;
public class App {
@SuppressWarnings("resource")
public static void main(String[] args) {
ApplicationContext ctx1 = new ClassPathXmlApplicationContext("spring_hibernate.xml");
Interface_ws_security_services service=(Interface_ws_security_services)ctx1.getBean("a");
//Ws_security ess=new Ws_security();
System.out.println("Done");
Ws_security ess =service.findByidws("ess1");
System.out.println(ess.getLogin());
System.out.println(ess.getPassword());
System.out.println(ess.getIPmax());
System.out.println(ess.getIPmin());
System.out.println("Done");
}
}
错误日志:
log4j:WARN No appenders could be found for logger(org.springframework.core.env.StandardEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'disableServiceBoxPageController' defined in URL [jar:file:/C:/Users/sayed/Desktop/DocumentationR3_33276/Client/lib/func_frwmwk_clt.jar!/com/lhs/ccb/cfw/sgu/solutionunits/servicebox/DisableServiceBoxPageController.class]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.lhs.ccb.cfw.sgu.solutionunits.servicebox.DisableServiceBoxPageController]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.lhs.ccb.func.ect.DefaultDictionary cannot be cast to com.lhs.ccb.cfw.wcs.errorhandling.CFWErrorDictionary
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1007)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:953)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:487)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:458)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:295)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:292)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:626)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:932)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:479)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.services.App.main(App.java:19)
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [com.lhs.ccb.cfw.sgu.solutionunits.servicebox.DisableServiceBoxPageController]: Constructor threw exception; nested exception is java.lang.ClassCastException: com.lhs.ccb.func.ect.DefaultDictionary cannot be cast to com.lhs.ccb.cfw.wcs.errorhandling.CFWErrorDictionary
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1000)
... 13 more
Caused by: java.lang.ClassCastException: com.lhs.ccb.func.ect.DefaultDictionary cannot be cast to com.lhs.ccb.cfw.wcs.errorhandling.CFWErrorDictionary
at com.lhs.ccb.cfw.wcs.solutionunit.AbstractPageController.<init>(Unknown Source)
at com.lhs.ccb.cfwutil.ExtendedAbstractPageController.<init>(Unknown Source)
at com.lhs.ccb.cfw.sgu.solutionunits.servicebox.DisableServiceBoxPageController.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148)
... 15 more
答案 0 :(得分:1)
DisableServiceBoxPageController
的构造函数中存在错误。您正试图将DefaultDictionary
投射到CFWErrorDictionary
中,这似乎不可能。
搜索违规行并尽可能将对象转换为正确的类型。
修改强>
如果问题与添加JAR本身有关,则可能是某个类存在冲突。确保您没有使用同一JAR的多个版本。
答案 1 :(得分:0)
尝试将业务层所需的文件放入单独的目录中。