外部JAR的Spring配置* .xml文件中找不到
我有一个不同的项目有像外部JAR的Spring配置* .xml文件中找不到
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
@Configuration
@ImportResource({ "/WEB-INF/assembly/appconfig.xml" })
public class DSPPlatformCommonSiteDefConfig {}
类现在干脆一个罐子X,我加入这个jar作为一个依赖。
并导入这个类,如:
@Configuration
@Import(DSPPlatformCommonSiteDefConfig.class)
public class ApplicationConfiguration {
}
所以基本上,我使用的是罐子的Spring配置文件在我的项目。
但是当我运行我的应用程序我得到这个错误:
消息:java.io.FileNotFoundException:类路径资源[WEB-INF /组装/ appconfig.xml]不能打开,因为它不存在 org.springframework.beans.factory.BeanDefinitionStoreException:IOException从类路径资源解析XML文档[WEB-INF/assembly/appconfig.xml];嵌套的异常是java.io.FileNotFoundException:类路径资源[WEB-INF/assembly/appconfig.xml]无法打开,因为它不存在
我不明白它为什么在类路径中查找。即使它是这样,jar也在我的类路径中。
您的问题似乎在@ImportResource
批注中的location的路径声明中。路径应该是文件的URI,不能是你声明的文件的URI。
一个例子可能是以下路径:
@ImportResource(locations={ "file:com/yourProjectName/assembly/appconfig.xml" })
谢谢你的回复。 是的! 这似乎是正确的。但由于它是一个外部的罐子,我无法改变它。 –
你有权限反编译jar类吗? –
嗨维沙尔,我不能改变这个外部JAR。 –