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

Maven更新项目时排除资源目录及application.properties,如何禁用该行为?

解决Maven更新时src/main/resources被自动排除的问题
  • 检查pom.xml的资源配置
    打开项目根目录下的pom.xml,确认<build>节点下的<resources>配置是否正确,避免误排除src/main/resources目录。正确的配置应包含该目录下所有文件,示例如下:

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
                <excludes>
                    <!-- 仅添加需要特定排除的文件,不要写** -->
                </excludes>
            </resource>
        </resources>
    </build>
    

    若存在错误的排除规则,删除后重新执行Maven更新。

  • 固定IDE的资源目录配置
    以IntelliJ IDEA为例:

    1. 打开File -> Project Structure(快捷键Ctrl+Alt+Shift+S)
    2. 选择Modules,找到当前项目模块,切换到Sources标签
    3. 找到src/main/resources目录,右键选择Mark Directory as -> Resources Root
    4. 清空该目录的Excluded列表中的**规则
    5. 进入Settings -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing,取消勾选Import Maven projects automatically,避免IDE自动覆盖手动设置,之后手动执行Maven更新即可。
  • 清除IDE缓存
    若IDE缓存导致配置异常,执行File -> Invalidate Caches...,选择Invalidate and Restart,重启后重新配置资源目录,再测试Maven更新。

  • 排查Maven插件或Profile影响
    检查pom.xml中是否有自定义Maven插件(如maven-resources-plugin的特殊配置)或激活的Profile,这些可能会修改资源目录处理规则,调整后重新测试。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 13:29:53