Tag: cdi wildfly

wildfly:从配置目录中读取属性

我正在尝试从我的wildfly配置文件夹中的属性文件中读取部署特定信息。 我试过这个: @Singleton @Startup public class DeploymentConfiguration { protected Properties props; @PostConstruct public void readConfig() { props = new Properties(); try { props.load(getClass().getClassLoader().getResourceAsStream(“my.properties”)); } catch (IOException e) { // … whatever } } 但显然这不起作用,因为配置文件夹不再在类路径中。 现在我找不到一个简单的方法来做到这一点。 我最喜欢的是这样的: @InjectProperties(“my.properties”) protected Properties props; 到目前为止,我在网上找到的唯一解决方案是制作我自己的OSGi模块,但我相信必须有一种更简单的方法(没有OSGi!)。 谁能告诉我怎么样?