Quarkus中quarkus.http.root-path配置变量未展开问题求助
问题解决:Quarkus构建阶段context-path配置异常
问题原因
quarkus.http.root-path 是构建时只读属性,其值必须在构建阶段确定。你仅在%dev,test环境配置了application.example.context_path,但默认构建阶段(通常对应prod环境)无该配置项,导致属性无法解析,抛出SRCFG00011异常。
解决方案(无需设置默认值,灵活配置)
1. 构建时直接传递参数
通过Maven参数直接指定quarkus.http.root-path的自定义值:
mvn clean install -Dquarkus.http.root-path=/your-custom-context
也可通过环境变量传递:
export QUARKUS_HTTP_ROOT_PATH=/your-custom-context mvn clean install
2. 构建时指定目标环境Profile
如果想复用dev或test环境的配置值,构建时指定对应Profile即可:
# 基于dev环境配置构建 mvn clean install -Dquarkus.profile=dev # 基于test环境配置构建 mvn clean install -Dquarkus.profile=test
3. 为构建环境添加专属配置
创建application-prod.yml(对应默认构建的prod环境),在其中配置对应路径值:
application: example: context_path: "/prod-example"
构建prod环境时会自动读取该配置,无需额外传参。
内容的提问来源于stack exchange,提问作者Dolphy the Reaper
相关产品推荐
相关产品推荐

