首页 > 解决方案 > Maven 中不存在 Java_Home

问题描述

我是 Maven 新手,并在我的机器中配置了它。我刚刚注意到在执行 mvn --version 时,cmd 输出中不存在 Java Home。这是输出:

Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Users\EJ\Desktop\Drivers\apache-maven-3.6.3\bin\..
Java version: 1.8.0_251, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_251\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

我的 JAVA_HOME 系统变量: JAVA_HOME CONFIG
这是 PATH: PATH CONFIG
这是我在 Eclipse 中制作的 Maven 项目的 POM 文件。我错过了什么吗?

<?xml version="1.0" encoding="UTF-8"?>

-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0">

<modelVersion>4.0.0</modelVersion>

<groupId>CucumberMaven</groupId>

<artifactId>ExpediaBooking</artifactId>

<version>0.0.1-SNAPSHOT</version>

<name>ExpediaBooking</name>

<!-- FIXME change it to the project's website -->


<url>http://www.example.com</url>


-<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<maven.compiler.source>1.8</maven.compiler.source>

<maven.compiler.target>1.8</maven.compiler.target>

</properties>


-<dependencies>


-<dependency>

<groupId>junit</groupId>

<artifactId>junit</artifactId>

<version>4.11</version>

<scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-junit -->



-<dependency>

<groupId>io.cucumber</groupId>

<artifactId>cucumber-junit</artifactId>

<version>5.7.0</version>

<scope>test</scope>

</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-java -->



-<dependency>

<groupId>io.cucumber</groupId>

<artifactId>cucumber-java</artifactId>

<version>5.7.0</version>

</dependency>

<!-- https://mvnrepository.com/artifact/io.cucumber/cucumber-core -->



-<dependency>

<groupId>io.cucumber</groupId>

<artifactId>cucumber-core</artifactId>

<version>5.7.0</version>

</dependency>

<!-- These are the selenium-webdriver dependencies -->


<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->



-<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>selenium-server</artifactId>

<version>3.141.59</version>

</dependency>

<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->



-<dependency>

<groupId>org.seleniumhq.selenium</groupId>

<artifactId>selenium-java</artifactId>

<version>3.141.59</version>

</dependency>

</dependencies>


-<build>


-<pluginManagement>

<!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->



-<plugins>

<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->



-<plugin>

<artifactId>maven-clean-plugin</artifactId>

<version>3.1.0</version>

</plugin>

<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->



-<plugin>

<artifactId>maven-resources-plugin</artifactId>

<version>3.0.2</version>

</plugin>


-<plugin>

<artifactId>maven-compiler-plugin</artifactId>

<version>3.8.0</version>

</plugin>


-<plugin>

<artifactId>maven-surefire-plugin</artifactId>

<version>2.22.1</version>

</plugin>


-<plugin>

<artifactId>maven-jar-plugin</artifactId>

<version>3.0.2</version>

</plugin>


-<plugin>

<artifactId>maven-install-plugin</artifactId>

<version>2.5.2</version>

</plugin>


-<plugin>

<artifactId>maven-deploy-plugin</artifactId>

<version>2.8.2</version>

</plugin>

<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->



-<plugin>

<artifactId>maven-site-plugin</artifactId>

<version>3.7.1</version>

</plugin>


-<plugin>

<artifactId>maven-project-info-reports-plugin</artifactId>

<version>3.0.0</version>

</plugin>


-<plugin>

<groupId>org.apache.maven.plugins</groupId>

<artifactId>maven-surefire-plugin</artifactId>

<version>2.20.1</version>

</plugin>

</plugins>

</pluginManagement>

</build>

</project>  

标签: mavenjava-home

解决方案


Java home ”输出似乎已从最新版本的 maven 中删除。引用github中的问题:

"显示的 Java 主页对应于属性 'java.home',它指向运行给定 Maven 实例的 JRE 安装。引起混淆的不是 $JAVA_HOME 的值。 "

以下是供您参考的github链接: https ://github.com/apache/maven/commit/9abfc88425601da4e756a80768c2215bb97e9725


推荐阅读