Windows安装Maven各版本

Maven下载官网:Maven – Download Apache Maven

 下载页面默认最新版的Maven,看需求,需要就下最新版的,如果不是的话建议下稳定版,就是降一两个版本,最新版有可能会出现jar包不兼容问题。

历史版本列表

 

 这里我选择20年的3.6.3版本。

 点击下载就行,下载完放在你想放的系统盘,再建个仓库文件夹。

然后接着再配置下远程仓库及本地仓库路径。

 

配置文件路径conf/setting.xml。

   <localRepository>E:\apache-maven-repository</localRepository>

这里是配得本地仓库的jar下载路径,就是下载下来jar包存放的位置。

 

依旧是这个文件下的mirrors下面建两个阿里云的远程仓库下载路径 。

<!--阿里远程仓库 -->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
    <mirror>
      <id>alimaven</id>
      <mirrorOf>central</mirrorOf>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
    </mirror>

修改完保存。

我这里是编辑,第一次的话就新建一个系统变量就好,系统环境变量也要配置下,添加好 

在Path环境变量下添加Maven的参数.%MAVEN_HOME%\bin

注意前后是用 ; 分割的。 

输入mvn -v查看版本号及安装情况。 

然后用idea配置下Maven的路径,配置文件路径,本地仓库路径即可。 

  • 10
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 在Maven中,可以通过配置多个JDK版本来运行项目。首先,需要确保系统中已经安装了多个JDK版本,并将它们添加到系统环境变量中。接下来,可以按照以下步骤来设置多个JDK版本: 1. 打开Maven安装目录下的`conf`文件夹,找到`settings.xml`文件,并用文本编辑器打开。 2. 在`settings.xml`文件中,找到`profiles`标签,并在其中添加多个`profile`子标签,每个子标签代表一个JDK版本。 3. 在每个`profile`子标签中,添加`id`和`activation`元素,分别用于标识和激活该JDK版本的配置。 4. 在每个`profile`子标签中,添加`properties`和`jdk.home`元素,用于指定该JDK版本的路径。 5. 最后,在`profiles`标签的外部,找到`activeProfiles`元素,并在其中添加要激活的JDK版本的`profile`的`id`。 以下是一个示例的`settings.xml`配置文件,其中包含两个JDK版本的配置: ``` <settings> ... <profiles> <profile> <id>jdk1.8</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <jdk.home>C:\Program Files\Java\jdk1.8</jdk.home> </properties> </profile> <profile> <id>jdk11</id> <properties> <jdk.home>C:\Program Files\Java\jdk11</jdk.home> </properties> </profile> </profiles> ... <activeProfiles> <activeProfile>jdk1.8</activeProfile> </activeProfiles> ... </settings> ``` 在上述示例中,`jdk1.8`被设置为默认激活的JDK版本。如果需要切换到`jdk11`,只需将`activeProfile`改为`jdk11`即可。 配置完成后,使用Maven运行项目时,会自动使用激活的JDK版本。 ### 回答2: 要在Maven中设置多个JDK版本,可以按照以下步骤进行操作: 1. 打开Maven安装目录,找到conf文件夹下的settings.xml文件。 2. 使用文本编辑器打开settings.xml文件。 3. 在<profiles>标签内添加一个新的profile,用于指定JDK版本。 ``` <profiles> <profile> <id>jdk8</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> </profile> </profiles> ``` 4. 可以重复以上步骤来添加其他JDK版本的profile。 5. 保存并关闭settings.xml文件。 现在,你可以在你的Maven项目中使用不同的JDK版本了。在项目的pom.xml文件中,可以使用以下配置指定使用哪个JDK版本: ``` <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.1</version> <configuration> <source>1.8</source> <target>1.8</target> </configuration> </plugin> </plugins> </build> ``` 在上述配置中,将<source>和<target>的值设置为你想要使用的JDK版本。 这样,当你构建或编译项目时,Maven将使用指定的JDK版本来执行。 ### 回答3: 在Maven的settings.xml文件中,可以通过配置多个profile来设置多个JDK版本。 首先,我们需要在settings.xml文件中添加多个profile,每个profile代表一个JDK版本,如下所示: ```xml <profiles> <profile> <id>jdk8</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <jdk.version>1.8</jdk.version> </properties> </profile> <profile> <id>jdk11</id> <properties> <jdk.version>11</jdk.version> </properties> </profile> </profiles> ``` 以上示例中,我们定义了两个profile,分别是jdk8和jdk11。其中,jdk8被设置为默认激活的profile。 接下来,我们需要在build节点的plugins节点中配置maven-compiler-plugin插件,用于指定使用的JDK版本。在这个插件的配置中,通过使用${jdk.version}来引用我们在profile中定义的jdk.version属性。 ```xml <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> <configuration> <source>${jdk.version}</source> <target>${jdk.version}</target> </configuration> </plugin> </plugins> </build> ``` 通过以上配置,当我们构建项目时,Maven会根据激活的profile来选择对应的JDK版本进行编译。 要使用其他的JDK版本,我们可以通过指定命令行参数来激活对应的profile。例如,要使用jdk11的话可以使用以下命令: ```shell mvn clean install -P jdk11 ``` 以上就是如何在Maven中设置多个JDK版本的方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值