[英]unable to access outside xml config file in spring boot jar
am trying to use an xml file from outside jar.now its getting null pointer exception我正在尝试使用 jar 外部的 xml 文件。现在它得到 null 指针异常
private static String getRequestConfigurationLocation() throws UnsupportedEncodingException
{
URL resourceURL = ConfigurationFactory.class.getResource(Configuration.XML_CONF);
//Assert.notNull(resourceURL, "Resource url is null : ");
String urlFilePath = resourceURL.getFile();
String actualFilePath = java.net.URLDecoder.decode(urlFilePath, StandardCharsets.UTF_8.name());
return actualFilePath;
}
Configuration配置
public class ConfigurationFactory
{
public static final String XML_CONF = "D:/DEV//X/X1/Service/target/conf/rConfiguration.xml";
}
how can i use external file in an executable jar如何在可执行 jar 中使用外部文件
error log错误日志
Caused by: java.lang.NullPointerException
In your property file try:在您的属性文件中尝试:
external.config=D:/DEV//X/X1/Service/target/conf/rConfiguration.xml external.config=D:/DEV//X/X1/Service/target/conf/rConfiguration.xml
Or annotate your configuration file with following或使用以下注释您的配置文件
@configuration @ImportResource("D:/DEV//X/X1/Service/target/conf/rConfiguration.xml") @configuration @ImportResource("D:/DEV//X/X1/Service/target/conf/rConfiguration.xml")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.