【发布时间】:2014-10-13 14:30:14
【问题描述】:
我正在尝试访问在 bean 中定义的属性,如下所示:
<bean id="reportdepositService" class="a.b.c.ServiceImpl">
<property name="reportDeposit" value="/WebContent/WEB-INF/dirName/" />
</bean>
ServiceImpl 类如下所示:
public class ServiceImpl implements IService {
private Resource springResource;
public Resource getSpringResource() {
return springResource;
}
public void setSpringResource(Resource springResource) {
this.springResource = springResource;
}
private File getSpringResourceFile() throws IOException{
Resource r = getSpringResource();
URL url = FileLocator.resolve(r.getURL());
return FileUtils.toFile(url);
}
public void doSomething(){
.. some logic .
File f = getSpringResourceFile();
}
在 ubuntu 机器上的 eclipse 中执行该代码可以正常工作,在 jenkins 上构建的应用程序在 ubuntu 上也可以正常工作。在 win7/64 上运行该应用程序,代码抛出以下异常:
OSGi resource[/WebContent/WEB-INF/springResource/|bnd.id=332|bnd.sym=a.b.server] cannot be resolved to URL because it does not exist
java.io.FileNotFoundException: OSGi resource[/WebContent/WEB-INF/springResource/|bnd.id=332|bnd.sym=a.b.server] cannot be resolved to URL because it does not exist
at org.springframework.osgi.io.OsgiBundleResource.getURL(OsgiBundleResource.java:228)
访问 Windows 托管系统上的属性需要什么? 有任何想法吗? 提前致谢
【问题讨论】:
标签: java windows spring tomcat osgi