更新时间:2023-09-17 12:12:22
java.home
是一个System属性,通常指向jre目录,并且指向一个不存在的jar时会出现错误.
java.home
is a System property which generally points to the jre directory and you are getting an error as you have pointed to a jar which doesn't exist.
如果要在pom文件中引用环境变量,请使用以下语法.
In case you want to refer to an environment variable within your pom file, use the below syntax.
${env.variable_name}
根据您的情况,应为${env.JAVA_HOME}
,如下所示
In your case, it should be ${env.JAVA_HOME}
as seen below
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.6.0</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/tools.jar</systemPath>
</dependency>
更新:正如lexicore所提到的,由于MAC JDK具有不同的文件结构,因此这不适用于MAC.
Update: As lexicore has mentioned, this wont work with MAC as the MAC JDK has a different file structure.