开发者

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.

And set that folder be 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.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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜