gpt4 book ai didi

java - 如何使用 Weblogic Server 使用 java 访问属性文件?

转载 作者:搜寻专家 更新时间:2023-11-01 03:27:47 24 4
gpt4 key购买 nike

我有一个属性文件 .properties,我可以在独立的 Java 类中加载该文件,如下所示:

Properties props = new Properties();
try {
FileInputStream fis =
new FileInputStream("D:\\Examples\\Simple\\src\\properties.xml");
props.loadFromXML(fis);
// props.list(System.out);
path = props.getProperty("path");
System.out.println("\nThe path property: "
+ props.getProperty("path"));
props.load(new FileInputStream(path));
filePath = props.getProperty("path");
System.out.println(filePath);
}
catch (IOException e) {
e.printStackTrace();
}

现在我需要实现允许我使用 Weblogic Server 加载属性文件的逻辑。所以基本上每当我更改 .prorties 文件中的任何内容时,我不需要每次都构建应用程序,它可以与服务器集成。我正在使用 Jdeveloper 和 Weblogic Server 10.3。我如何使用基于服务器的 java 文件设置属性文件?

最佳答案

在你的网络逻辑启动批处理文件中添加下面一行

设置 JAVA_OPTIONS=%JAVA_OPTIONS% -DconfigFile=文件路径

在您的 java 程序中使用

检索文件路径
String filePath = System.getProperty("configFile");

关于java - 如何使用 Weblogic Server 使用 java 访问属性文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8925666/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com