[../conf] 路径找不到Scala配置文件

今天需要引用一个Scala程序的jar包,该Scala程序通过沪深行情计算出信号点信息。我需要将信号点存入本地DB。

写好调用Scala的Service后,在单元测试Test中跑没问题,但是一旦启动Tomcat 在SpringMVC的 Task配置的定时任务中调用 或者在@Controller中调用,就会报错:

03-Jul-2017 09:43:37.831 严重 [http-nio-8080-exec-5] org.apache.catalina.core.StandardWrapperValve.invoke Servlet.service() for servlet [dispatcher] in context with path [] threw exception [Handler processing failed; nested exception is java.lang.ExceptionInInitializerError] with root cause
 org.aiotrade.lib.util.config.ConfigurationException: configDir is defined as [../conf] 
    but the 'development.conf' config file can not be found at [../conf/development.conf],

我打开jar包 发现在其根目录下确实有个development.conf 配置文件。于是拷贝出来,打包到我自己的web工程下。但是我尝试了将该配置文件打包到web程序的任何一级目录,依然报错找不到该配置文件。

这里写图片描述

单步调试进去,看到源码中对于Scala的配置源码:

    private Option configDir$lzycompute() {
        synchronized(this) {
            if(!this.bitmap$0) {
                this.configDir = .MODULE$.apply(scala.Predef..MODULE$.wrapRefArray((Object[])(new String[]{"../conf", "../etc"}))).find(new Serializable() {
                    public static final long serialVersionUID = 0L;

                    public final boolean apply(String x) {
                        File f = new File(x);
                        return f.exists() && f.isDirectory();
                    }
                });
                this.bitmap$0 = true;
            }

            BoxedUnit var10000 = BoxedUnit.UNIT;
        }

        return this.configDir;
    }

该段代码配置了 当在容器中运行时 会去lib库的上上级的conf目录下去找。因此在Tomcat容器中运行时,把development.conf 配置文件放到Tomcat的conf路径下,问题解决。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值