How to reference class from external jar file in spring.xml
This is my bean define in spring.xml
<bean id="hello" class="test.Hello" />
I export class Hello
to hello.jar
and place it to c:\customjar
.
This is an output
Caused by: org.springframework.beans.factory.CannotLoadBeanClassException:
Cannot find class [test.Hello] for bean with name 'hello' defined in class path resource [spring.xml];
nested exception is java.lang.Clas开发者_JAVA百科sNotFoundException: test.Hello
For xml file I can reference classpath by use something like this
<import resource="classpath:xxxxxx.xml"/>
But it doesn't work in my case.
EDIT
This is class sourcecode.
package test;
public class Hello {
public void someMethod() {
// do something here
}
}
and this is classpath setting.
%CLASSPATH% = XXXXXXXX;c:\customjar\hello.jar;
Spring can load classes from different jars, without any extra configuration. - For me it looks like the Hello class is really not in your running application.
精彩评论