码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • IntelliJ IDEA 使用 Maven 时不加载本地私服的最新版本快照(snapshot)JAR 包


    IntelliJ IDEA 使用 Maven 时不加载本地私服的最新版本快照(snapshot)JAR 包

    目录

    • IntelliJ IDEA 使用 Maven 时不加载本地私服的最新版本快照(snapshot)JAR 包
      • 1. 检查 settings.xml
      • 2. IDEA Maven 配置
      • 3. 强制更新 Snapshot
      • 4. 使用 IDEA 的 Maven 索引
      • 5. 清理缓存并重启 IDEA
      • 6. 检查网络设置
      • 7. 手动更新依赖
      • 总结
      • 结果展示
        • 错误情况
        • 正确情况

    以下是针对这个问题的详细解决方法:

    1. 检查 settings.xml

    确保你的 Maven settings.xml 文件中正确配置了私服仓库地址。通常,settings.xml 文件位于 ~/.m2/ 目录下。确认 和 部分的配置:

    <settings>
        <mirrors>
            <mirror>
                <id>my-private-repoid>
                <url>http://private-repo-url/repository/maven-snapshots/url>
                <mirrorOf>snapshotsmirrorOf>
            mirror>
        mirrors>
        <profiles>
            <profile>
                <id>defaultid>
                <repositories>
                    <repository>
                        <id>snapshotsid>
                        <url>http://private-repo-url/repository/maven-snapshots/url>
                        <snapshots>
                            <enabled>trueenabled>
                        snapshots>
                    repository>
                repositories>
                <pluginRepositories>
                    <pluginRepository>
                        <id>snapshotsid>
                        <url>http://private-repo-url/repository/maven-snapshots/url>
                        <snapshots>
                            <enabled>trueenabled>
                        snapshots>
                    pluginRepository>
                pluginRepositories>
            profile>
        profiles>
        <activeProfiles>
            <activeProfile>defaultactiveProfile>
        activeProfiles>
    settings>
    
    

    2. IDEA Maven 配置

    确保 IDEA 中的 Maven 配置正确。

    进入 Settings/Preferences -> Build, Execution, Deployment -> Build Tools -> Maven。
    检查 User settings file 路径是否正确指向你的 settings.xml 文件,并确保 Override 复选框已勾选。
    检查 Local repository 路径是否正确。

    3. 强制更新 Snapshot

    确保 Maven 在构建时强制更新 Snapshots。

    进入 Settings/Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Runner。
    勾选 Force update of Snapshots/Releases。

    4. 使用 IDEA 的 Maven 索引

    尝试使用 IDEA 的 Maven 项目索引功能。

    进入 Settings/Preferences -> Build, Execution, Deployment -> Build Tools -> Maven -> Importing。
    勾选 Use Maven 3.x compiler plugin 和 Import Maven projects automatically。

    5. 清理缓存并重启 IDEA

    清除 IDEA 的缓存并重启。

    进入 File -> Invalidate Caches / Restart… -> Invalidate and Restart。

    6. 检查网络设置

    确认 IDEA 能够访问到私服仓库。确保防火墙或代理设置不会阻止 IDEA 访问私服。

    7. 手动更新依赖

    如果上述方法仍然无效,尝试手动更新依赖。

    打开终端,导航到你的项目目录。
    运行以下命令:

    mvn clean install -U
    

    这将强制更新所有 Snapshots 和 Releases。

    总结

    通过以上步骤,应该可以排查并解决 IDEA 使用 Maven 时不加载本地私服临时版本 JAR 包的问题。

    结果展示

    我的IDEA版本是2024.3.4,我首先进入 Settings/Preferences -> Build, Execution, Deployment -> Build Tools -> Maven,这有个始终更新快照选项(Always update snapshots),勾选上

    然后我把本地私服jar包所属文件夹删除

    最后清理并重新导入 Maven 项目,在 IntelliJ IDEA 中,右键点击项目根目录中的 pom.xml 文件。
    选择 Maven -> reimport,重新加载后拉取的快照版本被加载了
    在这里插入图片描述

    错误情况

    在这里插入图片描述

    正确情况

    在这里插入图片描述


    👑 天下英雄出我辈,一入江湖岁月催
    我是热爱生活的「 无间行者 」,努力把实践过的解决方案分享给大家
    如果这篇文章对你有用,一键三连,感谢你的鼓励,让我知道你在看

    请添加图片描述


  • 相关阅读:
    AI大模型低成本快速定制法宝:RAG和向量数据库
    直播系统开发:基于Nginx与Nginx-rtmp-module实现
    JS判断相等或者不等于(==、===、!=、!==)运算符
    cesium 雷达扫描 (扫描线)
    React项目中如何实现一个简单的锚点目录定位
    sqli-labs/Less-52
    王道书P149 T3(二叉树链式存储实现)
    【Kafka】CDH 中配置 Kafka MirrorMaker 实现 Kafka 集群消息同步
    在PHP8中向数组添加元素-PHP8知识详解
    程序员创始股东协议
  • 原文地址:https://blog.csdn.net/qq_35606010/article/details/139476880
  • 最新文章
  • 沪漂五周年了:我越来越迷茫了
    Agentic Skill Routing 实战:别再把所有 Skill 塞进 AI Agent 上下文
    MySQL-Seconds_behind_master的精度误差
    [MAF预定义ChatClient中间件-03]CachingChatClient——利用缓存省钱省时间
    AI的至暗历史:从万众期待到被政府撤资,AI的两次死亡徘徊
    Agent OS :五种驯服不确定性的范式
    PortSwigger SQL注入LAB11
    数据库即时编译JIT
    [Begin]AI Learn Data Day 0
    深度学习进阶(二十七)现代 LLM 的核心架构设计其二:SwiGLU
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
小工具 小游戏
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1

京公网安备 11010502049817号