[英]How to reference class from external jar file in spring.xml
This is my bean define in spring.xml 这是我在spring.xml中定义的bean
<bean id="hello" class="test.Hello" />
I export class Hello
to hello.jar
and place it to c:\\customjar
. 我将
Hello
类导出到hello.jar
并将其放置到c:\\customjar
。
And set that folder be WINDOWS CLASSPATH . 并将该文件夹设置为WINDOWS CLASSPATH 。
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.ClassNotFoundException: test.Hello
For xml file I can reference classpath by use something like this 对于xml文件,我可以通过使用类似这样的东西来引用类路径
<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. Spring可以从不同的jar加载类,而无需任何额外的配置。 - For me it looks like the Hello class is really not in your running application.
-对我来说,Hello类确实不在您正在运行的应用程序中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.