maven-3.9.12的conf配置settings.xml

复制代码
<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 https://maven.apache.org/xsd/settings-1.2.0.xsd">

  <localRepository>F:\java\repository</localRepository>
  <pluginGroups></pluginGroups>
  <proxies></proxies>
  <servers></servers>

  <mirrors>

    <mirror>
      <id>aliyunmaven</id>
      <mirrorOf>central,jcenter</mirrorOf>
      <name>阿里云公共仓库</name>
      <url>https://maven.aliyun.com/repository/public</url>
    </mirror>
	
   
  </mirrors>
  
  
  

  <!-- 简化 profiles 配置 -->
  <profiles>
    <profile>
      <id>aliyun</id>
      <repositories>
        <repository>
          <id>aliyun</id>
          <name>Aliyun Maven Repository</name>
          <url>https://maven.aliyun.com/repository/public</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <!-- 添加 Maven Central 作为备用 -->
        <repository>
          <id>central</id>
          <name>Maven Central</name>
          <!--  <url>https://repo.maven.apache.org/maven2</url> -->
          <url>https://repo1.maven.org/maven2/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
	  
	 <profile>
      <id>jdk21</id>
      <activation>
        <activeByDefault>true</activeByDefault>
        <jdk>21</jdk>
      </activation>
      <properties>
        <maven.compiler.source>21</maven.compiler.source>
        <maven.compiler.target>21</maven.compiler.target>
        <maven.compiler.compilerVersion>21</maven.compiler.compilerVersion>
      </properties>
    </profile>
  </profiles>

<!-- 激活 profile -->
  <activeProfiles>
    <activeProfile>aliyun</activeProfile>
    <activeProfile>jdk21</activeProfile>
  </activeProfiles>
</settings>

如果依赖一直添加不到idea的external libraries中,可以参考下列几个命令:

复制代码
# 1. 先清理所有
mvn clean

# 2. 强制更新所有依赖
mvn dependency:sources

# 3. 或者使用离线模式先下载
mvn dependency:go-offline

# 4. 重新编译
mvn compile -U

# 5. 重新生成Wrapper文件,指定maven版本
mvnw wrapper:wrapper -Dmaven=3.9.12
# 或
mvn wrapper:wrapper -Dmaven=3.9.12

# 6.清理idea的缓存
mvnw.cmd -U clean

# 7. 查看项目使用的mvn和jdk版本,在项目根目录执行
./mvnw -v  # Windows: mvnw.cmd -v

如果还是不行,可以删除项目下的idea文件,重新打开,然后编译compile 和 install试一下

相关推荐
摇滚侠1 小时前
Maven 入门+高深 单一架构案例 54-59
java·架构·maven·intellij-idea
VidDown1 小时前
Webhook 调试器:让第三方回调“原形毕露”
java·开发语言·javascript·编辑器·postman
折哥的程序人生 · 物流技术专研2 小时前
Java 23 种设计模式:从踩坑到精通 | 原型模式 —— 克隆对象,深拷贝与浅拷贝的坑你踩过吗?
java·设计模式·架构·原型模式·单一职责原则
装不满的克莱因瓶2 小时前
基于 OpenResty 扩展开发实现动态服务注册与发现能力
java·开发语言·架构·openresty
程序员小羊!2 小时前
06Java 异常机制与常用类
java
weixin_523185322 小时前
Java基础知识总结(四):引用数据类型与参数传递机制
java·开发语言·python
宸津-代码粉碎机3 小时前
Spring AI企业级实战|从RAG优化到Agent多工具调度
java·大数据·人工智能·后端·python·spring
噢,我明白了3 小时前
QueryWrapper的使用
java
Chase_______3 小时前
【Java基础 | 15】集合框架(中):Set、HashSet、TreeSet 与哈希表
java·windows·散列表
摇滚侠3 小时前
Maven 入门+高深 微服务案例 122-125
java·微服务·maven