我使用Spring JDBC模板开发了一个DAO war项目,该模板中包含applicationContext.xml并导出为jar。然后,我创建了另一个jar项目,该项目导入了DAO jar,但它抛出了堆栈跟踪。
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [com.breeze.bis.dao.service.jdbcTemplate] for bean with name 'genericDaoImpl' defined in class path resource [applicationContext.xml]; nested exception is java.lang.ClassNotFoundException: com.breeze.bis.dao.service.jdbcTemplate
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1263)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:581)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1332)
at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:898)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:588)
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.breeze.dao.Main.main(Main.java:28)
Caused by: java.lang.ClassNotFoundException: com.breeze.bis.dao.service.jdbcTemplate
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.springframework.util.ClassUtils.forName(ClassUtils.java:258)
at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:415)
at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1284)
at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1255)
... 9 more
DAO jar作为库导入,在构建路径中需要项目以及eclipse中的order和export选项卡,但是由于jar由提及类组成,因此URLClassLoader无法加载类。
请帮忙。
感谢。
答案 0 :(得分:0)
由于applicationContext.xml中的类名错误,线程已关闭