开发者

How to reference class from external jar file in spring.xml

开发者 https://www.devze.com 2023-01-27 23:35 出处:网络
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 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

精彩评论

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