Skip to content

[Bug] Maven 多模块项目无法把聚合根设为运行工作目录,相对路径配置全部失效 #2147

Closed

Description

@mos1128

Platform / 平台

Windows

Area / 模块

Maven

Lithe version / Lithe 版本

0.8.5

Priority / 优先级

P1 / 尽快处理:使用体验大幅下降,但通常仍可继续使用

OS and architecture / 操作系统与架构

Windows 11, x64

Environment / 环境信息

JDK: OpenJDK 21.0.2 (Oracle)
Maven: Apache Maven 3.10.0
JDT LS: 未安装
插件: io.github.lithe-idea.maven-build 1.0.1

Steps to reproduce / 复现步骤

  1. 新打开一个 Maven 多模块项目:聚合根 sz-boot-parent,应用模块 sz-service/sz-service-admin
  2. 应用模块的配置放在聚合根下 sz-boot-parent/config/local/*.yml,application.yml 用 spring.config.import 导入 12 个,例如 file:config/local/mysql.yml
  3. 等 Maven 插件检测完成,运行配置列表里出现自动生成的 AdminApplication
  4. 点运行 → Config data resource 'file [config\local\sa-token.yml]' ... does not exist

Expected behavior / 预期行为

应用在聚合根 sz-boot-parent 下运行,12 个 file:config/local/*.yml 正常加载。

Actual behavior / 实际行为

Spring 启动阶段失败:

Config data resource 'file [config\local\bi.yml]' via location 'file:config/local/bi.yml' does not exist

进程的工作目录落在模块目录 sz-service/sz-service-admin,聚合根下的 config 找不到。

解决方案: 编辑该运行配置,把底部「保存到」主动下拉点再一下「仅本机」,再运行 → 成功。在两个不同项目均试验通过。原因未知。

Logs or diagnostic output / 日志或诊断输出

[INFO] Reactor Summary for sz-boot-parent 1.2.5-beta-SNAPSHOT:
[INFO] BUILD SUCCESS
[INFO] Total time:  10.917 s

12:50:27.530 [main] ERROR org.springframework.boot.diagnostics.LoggingFailureAnalysisReporter -- 

***************************
APPLICATION FAILED TO START
***************************

Description:

Config data resource 'file [config\local\bi.yml]' via location 'file:config/local/bi.yml' does not exist

Action:

Check that the value 'file:config/local/bi.yml' at class path resource [application.yml] - 21:9 is correct, or prefix it with 'optional:'

Screenshots or recordings / 截图或录屏

No response

Checklist / 提交前检查

  • I searched existing issues for duplicates. / 我已搜索现有 Issue,确认没有重复报告。
  • I removed secrets and personal data from the report. / 我已从报告中移除敏感信息和个人数据。

Activity

  1. added
    bug
    on Nov 18, 2026
  2. added
    review: medium
    on Nov 18, 2026
  3. mos1128 commented on Nov 19, 2026

    @mos1128
    Author

    补充

    主问题

    自动检测的 run configuration 不会把 workingDirectory 传给插件,进程落在 Maven 模块目录,
    file:config/local/*.yml 全部失效。必须写入一份本地覆盖后才生效。

    次问题(更隐蔽,也更容易让人迷失方向)

    runconfig_dialog.go:1092 的 runConfigDialogSaveOrder 只收集 dirty 的 draft:

    case draft == nil || !draft.dirty() || ...:
        // 跳过
    

    而「确定」按钮只判断 Disabled(busy),不判断 dirty(runconfig_dialog_view.go:601)。
    结果:用户打开一个自动检测出的配置、不改任何字段、点「确定」——界面正常关闭,
    看起来保存成功,实际一个文件都没写。

    复现:

    1. 删掉项目下的 .lithe 目录
    2. 打开 AdminApplication 的编辑窗,不修改任何字段,直接点「确定」
    3. 检查 .lithe —— 不存在
    4. 在「运行时参数」里加任意一行(例如 -Dlithe.cwd=1),再点「确定」
    5. .lithe/run/plugin/io.github.lithe-idea.maven-build.local.toml 生成,cwd = ".",随后运行成功

    建议:点「确定」时若没有任何 dirty 的 draft,应写入当前表单状态(用户意图是"固化这份配置"),
    或者至少给出提示,而不是静默成功。


    • 没文件 → 持久层没有这条 → launchOptions 空 → 插件 RunPreparation.java:123 回落 projectPath(模块目录)
    • 有文件 → 持久层有 cwd = "." → launchOptions 带值 → cwd = 工作区根
  4. 1lck commented on Nov 20, 2026

    @1lck
    Owner

    已合入双向修复并通过联合端到端验证:

  5. 1lck commented on Nov 20, 2026

    @1lck
    Owner

    (更正上条注释中 shell 转义丢失的字段名):桌面端 PR #2222 修复了运行配置编辑窗对未修改的 generated 配置显式选择 Save to 作用域时标记 dirty 并保存;Maven 插件 PR Lithe-IDEA/lithe-plugin-maven#39 将默认 workingDirectory 回退到工作区构建根 request.root。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugissue-form:bugreview: medium

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions