所有
我使用以下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
- 类从罐子里加载
- 从分离的罐子中加载spring和其他依赖项
- 加载了Spring上下文(新的ClassPathXmlApplicationContext(“ spring-context / applicationContext.xml”))
- my.properties加载到PropertyPlaceholderConfigurer(“ classpath:my.properties”)
- 如果我将.config文件放在文件系统之外,然后将资源网址更改为“ file:”,则一切似乎都很好...
有小费吗?