加载属性文件WebSphere Liberty

时间:2016-05-11 17:14:29

标签: websphere websphere-liberty

我有一个简单的应用程序,它使用Spring从类路径加载属性文件。将此应用程序部署到WebSphere Liberty 8.5.5时,会生成FileNotFoundException

  

嵌套异常是java.io.FileNotFoundException:无法打开ServletContext资源[/myprops.properties]

这是我的春天@Configuration类:

@Configuration
@Profile("dev")
@PropertySource("classpath:/myprops.properties")
public class AppConfigDev extends AppConfig {
  ...
}

我想知道我的属性文件应该位于Liberty目录结构的哪个位置?

1 个答案:

答案 0 :(得分:0)

在注释中使用前缀classpath:表示将通过classpath调用从WebSphere,ClassLoader.getResources(...)中获取给定的属性文件。

参考:http://docs.spring.io/spring/docs/3.0.x/spring-framework-reference/html/resources.html#resources-classpath-wildcards

您需要为Websphere Liberty创建一个包含所有属性文件的jar才能加载它们。

价: 1. https://developer.ibm.com/answers/questions/13384/websphere-liberty-8-5-setting-java-classpath.html
2. Websphere Liberty 8.5: Setting Java classpath

相关问题