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试一下

相关推荐
JH30732 小时前
SpringBoot 优雅处理金额格式化:拦截器+自定义注解方案
java·spring boot·spring
工程师老罗2 小时前
YoloV1数据集格式转换,VOC XML→YOLOv1张量
xml·人工智能·yolo
CHHYQMGDCDZu3 小时前
光伏系统参数
maven
Coder_Boy_3 小时前
技术让开发更轻松的底层矛盾
java·大数据·数据库·人工智能·深度学习
invicinble3 小时前
对tomcat的提供的功能与底层拓扑结构与实现机制的理解
java·tomcat
较真的菜鸟4 小时前
使用ASM和agent监控属性变化
java
黎雁·泠崖4 小时前
【魔法森林冒险】5/14 Allen类(三):任务进度与状态管理
java·开发语言
qq_12498707535 小时前
基于SSM的动物保护系统的设计与实现(源码+论文+部署+安装)
java·数据库·spring boot·毕业设计·ssm·计算机毕业设计
Coder_Boy_5 小时前
基于SpringAI的在线考试系统-考试系统开发流程案例
java·数据库·人工智能·spring boot·后端
Mr_sun.5 小时前
Day06——权限认证-项目集成
java