[英]Spring Import Can't See Resources
I'm using Spring to handle my dependency injection and I am currently writing a jar that makes use of a homegrown logging-1.0.jar
that I also made some time ago. 我正在使用Spring来处理依赖项注入,并且我当前正在编写一个jar,该jar使用了我不久前制作的本地
logging-1.0.jar
。 I am writing this inside Eclipse, which may be important. 我正在Eclipse中编写此代码,这可能很重要。
That logging-1.0.jar
has a critical config file in it called logging-base.xml
where all sorts of environmental properties get set so that my logger works correctly. 该
logging-1.0.jar
有一个名为logging-base.xml
的关键配置文件,其中设置了各种环境属性,以便我的记录器可以正常工作。
My new jar is compiling/building in Ant fine, but at runtime is throwing an exception stating: 我的新jar可以使用Ant很好地进行编译/构建,但是在运行时抛出异常,说明:
Exception in thread "main"
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Failed to import bean definitions from URL location
[classpath:logging-base.xml] Offending resource: class path resource
[spring/client-config.xml]; nested exception is
org.springframework.beans.factory.parsing.BeanDefinitionParsingException:
Configuration problem: Unable to locate Spring NamespaceHandler for XML schema
namespace [http://camel.apache.org/schema/spring]
Offending resource: class path resource [logging-base.xml]
So it seems that Spring cannot find my logging-base.xml
file as its not "in the classpath". 因此,似乎Spring找不到我的
logging-base.xml
文件,因为它不在“类路径中”。 In my project I have a lib/
directory where all of my dependent jars are stored. 在我的项目中,我有一个
lib/
目录,其中存储了所有依赖的jar。 When I copy a new jar into this directory, I just right-click it and go Build Path >> Add to Build Path and Eclipse makes a reference of that jar available to the runtime. 当我将一个新的jar复制到该目录中时,只需右键单击它,然后转到Build Path >> Add to Build Path ,Eclipse便将该运行时可用的jar的引用。
Of all the jars under my lib/
directory, logger-1.0.jar has a distinct icon next to its name in the package explorer. 在我的
lib/
目录下的所有jar中, logger-1.0.jar在软件包浏览器中的名称旁边都有一个明显的图标。 Its icon has a little tiny question-mark ("?") in it. 它的图标中有一个小的问号(“?”)。
So I'm guessing that, somehow, my logging jar isn't configured correctly, and as a result, isn't adding its logging-base.xml
file to the classpath. 因此,我猜测某种程度上我的日志记录jar配置不正确,因此没有将其
logging-base.xml
文件添加到类路径中。 As such, at runtime, Spring can't find it. 因此,在运行时,Spring找不到它。
But that's where my knowledge of Eclipse and Spring grinds to a halt. 但这就是我对Eclipse和Spring的了解而停止的地方。
Any ideas? 有任何想法吗?
I think the issue might be with spring handlers, You might have defined this name space http://camel.apache.org/schema/spring in your client-config.xml, Spring usually has name space handlers defined for every name space that is defined in the application context. 我认为问题可能出在Spring处理程序上,您可能已经在client-config.xml中定义了这个名称空间http://camel.apache.org/schema/spring,Spring通常为每个命名空间定义了名称空间处理程序在应用程序上下文中定义。 These handlers are defined in a file called spring.handlers and are included in the respective jars in this case (camel-spring-X.jar).
这些处理程序在名为spring.handlers的文件中定义,在这种情况下,它们包含在相应的jar中(camel-spring-X.jar)。
您可能要添加xerces.jar
并在jre6\\lib\\ext
目录中,只需尝试一下即可。因为它帮助我解决了这个问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.