我想在Spring中加载文件。 该文件包含基于OpenRules引擎的规则。 问题是,当我使用Spring BootRun它正确加载。 但是,当我试图在外部Tomcat中部署相同的文件时,我收到错误FileNotFound。在外部Tomcat容器中加载文件vs Bootrun
我提的是在以下方式中的属性文件的路径:
rules.open.main.decision.path=file:rules/main/Decision.xls
规则文件夹是直属项目文件夹。
在Java中我加载文件:
public Decision getDecisionEngine(){
String decisionName = "CustomerPreventStrategies";
//String fileName = "file:rules/main/Decision.xls";
String fileName = env.getProperty("rules.open.main.decision.path");
System.out.println("rules.open.main.decision.path:"+fileName);
Decision decision = new Decision(decisionName,fileName);
return decision;
}
当我创造我保持它在2个位置外的Tomcat的WAR。但这并没有帮助。
war {
baseName = 'MyOpenRules'
version = '0.1.0'
from("rules") {
into("WEB-INF/classes/rules")
}
from("rules") {
into("rules")
}
}
我越来越:
Caused by: java.io.FileNotFoundException: rules\main\Decision.xls (The system cannot find the path specified)
经过试验和错误,我发现外部的Tomact,如果我保留**规则**文件夹下的** tomcat ** **斌**它工作正常。但无法解释为什么。 – user2110074