【发布时间】:2012-11-14 00:50:14
【问题描述】:
快速提问。 当它们在 webApp 使用的另一个 jar 中时,您可以在 applicationContext.xml 中引用 Spring 类吗?
JAR(一个包含我所有的 servries 和 daos 等的通用 jar)在 WAR 文件中,但是当我尝试通过 applicationContext.xml 引用服务时,我收到以下错误:-
Error creating bean with name 'com.myproject.common.test.impl.TestServiceImpl' defined in ServletContext resource [/WEB-INF/context/spring-context.xml]: Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition
(注意spring-context.xml导入到applicationContext.xml中没有错误。)
我的上下文 XML:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="com.myproject.common.test.impl.TestServiceImpl">
<property name="genericDao" ref="genericDao" />
</bean>
</beans>
我的 App 包都在 com.myproject.web 下 我的常用 JARS 都在 com.myproect.common 下
【问题讨论】:
-
一旦你做了@combinatorics 提到的事情。确保 jar 文件在您的类路径中。
-
为 MasterV 干杯,它成功了。
标签: java spring mapping applicationcontext