You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Typesafe Config中include "application"失效问题求助

解决Typesafe Config无法加载Jar内application.conf的问题

问题原因

当通过-Dconfig.file指定外部配置文件时,Typesafe Config的include "application"指令会默认从外部配置文件所在目录查找application.conf,而非Jar包内类路径中的配置文件,导致Jar内的sub-title配置未被加载,触发缺失报错。

解决方案

修改外部的application-test.conf,在include指令中添加classpath:前缀,明确指定从类路径(包含Jar包)加载原配置:

include "classpath:application"
title: "test-outside"

验证启动命令

保持原启动命令不变:

java -Dconfig.file=application-test.conf -jar scala-spark-maven-1.0-SNAPSHOT-jar-with-dependencies.jar

此时程序会先加载Jar内classpath:application的配置,再用外部配置中的title覆盖,同时保留sub-title参数。

内容的提问来源于stack exchange,提问作者Alexander Lopatin

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 13:55:16