全部
我创建了一个包含以下 MANIFEST.MF 的 jar 文件:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.3
Created-By: 1.6.0_25-b06 (Sun Microsystems Inc.)
Main-Class: my.Main
Class-Path: . lib/spring-core-3.2.0.M2.jar lib/spring-beans-3.2.0.M2.jar
在其根目录下有一个名为my.config的文件,该文件在我的spring-context.xml中被引用如下:<bean id="..." class="...">
<property name="resource" value="classpath:my.config" />
</bean>
如果我运行JAR文件,除了加载特定文件的过程之外,一切看起来都很正常。Caused by: java.io.FileNotFoundException: class path resource [my.config] cannot be resolved to absolute file path because it does not reside in the file system: jar:file:/D:/work/my.jar!/my.config
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:205)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at eu.stepman.server.configuration.BeanConfigurationFactoryBean.getObject(BeanConfigurationFactoryBean.java:32)
at eu.stepman.server.configuration.BeanConfigurationFactoryBean.getObject(BeanConfigurationFactoryBean.java:1)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 22 more
- 类从jar包内部加载
- Spring和其他依赖项从不同的jar包中加载
- Spring上下文被加载 (new ClassPathXmlApplicationContext("spring-context/applicationContext.xml"))
- my.properties被加载到PropertyPlaceholderConfigurer ("classpath:my.properties")
- 如果我将我的.config文件放在文件系统之外,并将资源URL更改为“file:”,一切似乎都很好...
有什么提示吗?