Maven能否在POM文件内部引用JAVA_HOME?

huangapple go评论61阅读模式
英文:

Can Maven reference JAVA_HOME from inside the POM file

问题

以下是翻译好的内容:

在 POM 文件中是否可以使用 $JAVA_HOME 的引用来设置属性?

<executable><$JAVA_HOME>/bin/javac</executable>

我这样做的原因是我唯一能够让 Maven 使用正确的编译器版本的方法是通过设置 <executable>。但是我不想在 POM 文件中硬编码 JAVA_HOME 的位置。

英文:

Is it possible to set a property in a POM file with reference to $JAVA_HOME?

<executable><$JAVA_HOME>/bin/javac</executable>

The reason I am doing this is the only way I can get maven to use the correct compiler version is by setting the <executable>. But I don't want to hard-code the JAVA_HOME location in the pom file.

答案1

得分: 5

你可以使用 ${env.ANY_ENV_VARIABLE} 在 pom.xml 文件中获取环境变量。
所以在你的情况下,只需使用 ${env.JAVA_HOME}

英文:

You can use ${env.ANY_ENV_VARIABLE} to get env variables in pom.xml.
So just use ${env.JAVA_HOME} in your case

huangapple
  • 本文由 发表于 2020年7月23日 15:24:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/63048969.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定