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

IntelliJ多模块项目资源文件夹未被处理问题求助

多模块项目资源识别&编译问题解决

1. 检查IntelliJ IDEA模块配置

  • 打开File > Project Structure > Modules,选中对应子模块(Child A/Child B)
  • 切换到Sources标签,确认src/main/resources被标记为Resources(蓝色文件夹图标),若未标记,右键该文件夹选择Mark Directory as > Resources Root
  • 切换到Paths标签,确认Output path和Test output path指向子模块自身的target/classes和target/test-classes,而非父模块的out目录

2. 修正子模块Maven资源配置

在子模块的pom.xml中明确资源路径,避免继承父模块的错误配置:

<build>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </resource>
    </resources>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <includes>
                <include>**/*</include>
            </includes>
        </testResource>
    </testResources>
</build>
  • 若父模块有统一build配置,检查是否覆盖了子模块资源路径,必要时在子模块中添加上述配置覆盖父设置

3. 清理IDEA缓存并重建项目

  • 执行File > Invalidate Caches...,勾选Clear file system cache and local history,点击Invalidate and Restart
  • 重启后在Maven面板中,依次执行子模块的clean > compile > package命令,确认子模块下生成target文件夹,且target/classes/db/changelog/db.changelog-master.yml存在

4. 调整IDEA编译输出设置

  • 打开File > Settings > Build, Execution, Deployment > Compiler,勾选Build Project automatically
  • 切换到Build, Execution, Deployment > Build Tools > Maven > Runner,勾选Delegate IDE build/run actions to Maven,让IDEA完全使用Maven编译逻辑,避免路径冲突

5. 确认Liquibase配置路径

检查子模块的application.yml(或properties)中Liquibase路径配置,确保指向子模块资源目录:

spring:
  liquibase:
    change-log: classpath:db/changelog/db.changelog-master.yml

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.29 13:59:52