Apache WS44J 没有正确获取环境变量

Apache WS44J not taking environment variables correctly

我的 spring 引导应用程序中有一个使用环境变量的属性文件

org.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=${env:keyStorePassword}
org.apache.ws.security.crypto.merlin.keystore.alias=${env:keyAlias}
org.apache.ws.security.crypto.merlin.keystore.file=${env:keyStoreFilePath}

但是提示找不到文件,同时提供了文件的路径。所以它正确地从环境文件中提取值。我还复制了文字值而不是环境变量并将其放入属性文件中,并且效果很好。为什么我从环境中拉取时说找不到文件?

这是错误日志

17:06:12.537 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.util.Loader - Trying to find [<file>] using org.springframework.boot.loader.LaunchedURLClassLoader@38af3868 class loader.
17:06:12.542 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.util.Loader - Trying to find [<file>] using org.springframework.boot.loader.LaunchedURLClassLoader@38af3868 class loader.
17:06:12.559 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.util.Loader - Trying to find [<file>] using ClassLoader.getSystemResource().
17:06:12.568 [http-nio-8080-exec-1] DEBUG org.apache.ws.security.components.crypto.Merlin - <file> (No such file or directory)
java.io.FileNotFoundException: ${env:keyStoreFilePath} (No such file or directory)

标签与环境变量中的文件路径完全相同。

感谢您提供的任何帮助。

我解决了这个错误,由于我仍然不完全理解的原因,环境变量以某种不同的格式存储。因此,相反,我使用一些好的旧 java.

将变量注入到属性文件中
try {
    PropertiesConfiguration props = new PropertiesConfiguration(System.getenv("SIGNATURE_PROPS_FILE"));
    props.setProperty("org.apache.ws.security.crypto.merlin.keystore.password", System.getenv("KEY_STORE_PASSWORD"));
    props.setProperty("org.apache.ws.security.crypto.merlin.keystore.alias", System.getenv("KEY_ALIAS"));
    props.setProperty("org.apache.ws.security.crypto.merlin.keystore.file", System.getenv("KEY_STORE_FILE"));
    props.save();
    logger.debug("** signature.properties updated Successfully!! **");
} catch (ConfigurationException e) {
    logger.error(e.getMessage());
}