如何在Eclipse启动配置中使用变量进行类路径定义? [英] How to use variables for classpath definition in Eclipse launch configurations?
问题描述
我已经发现有一个名为 M2_REPO 的类路径变量引用但是如何在下面的类路径定义中使用这个变量来替换绝对路径?
< listAttribute key =org.eclipse.jdt.launching.CLASSPATH>
...
< listEntry value =& lt;?xml version =& quot; 1.0& quot; encoding =& quot; UTF-8& quot;?& ;& lt; runtimeClasspathEntry externalArchive =& quot; C:/ Dokumente und Einstellungen / 050967 / .m2 / repository / com / google / gwt / gwt-dev / 2.0.3 / gwt-dev-2.0.3.jar&路径=& 3& quot; type =& 2& quot; /& gt;/>
...
< / listAttribute>或者有一种方法可以包含一个环境变量(例如Windows'%)
< USERPROFILE%可以帮助)?
编辑启动配置。
转到类路径选项卡。
专注于用户条目。
单击高级按钮。
- 要添加基于
类路径变量的条目,选择添加类路径变量,然后单击确定。将打开一个对话框。专注于 M2_REPO
,然后点击扩展按钮。选择您的JAR文件。 - 要添加基于系统环境变量的条目,请选择添加变量字符串,然后在编辑框中在下面,键入:$ $ $ $ $ $ $ $ $ $ en $ $ $ $ en $ $ $例如,如果您的系统环境变量为
MYVAR
,并且JAR文件位于subdir / myfile.jar
之下,则应键入$ {env_var:MYVAR} /subdir/myfile.jar
。
In our project we use Eclipse launch configurations which are under version control to be shared with all developers. Now it is necessary to include an external archive to a launch configuration file's classpath. Fortunately the required archive is in every developer's local Maven repository.
I already found out that there is a classpath variable called M2_REPO which references to the local Maven repository (being valid for any developer).
But how to use this variable in the following classpath definition to replace the absolute path?
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
...
<listEntry value="<?xml version="1.0" encoding="UTF-8"?><runtimeClasspathEntry externalArchive="C:/Dokumente und Einstellungen/050967/.m2/repository/com/google/gwt/gwt-dev/2.0.3/gwt-dev-2.0.3.jar" path="3" type="2"/>"/>
...
</listAttribute>
Or is there a way to include an environment variable (e.g. Windows' %USERPROFILE%
could help)?
Edit your launch configuration. Go to the "classpath" tab. Focus on "User Entries". Click the "Advanced" button.
- To add an entry based on a classpath variable, select Add classpath variable and click OK. A dialog will open. Focus on
M2_REPO
and click the "Extend" button. Select your JAR file. - To add an entry based on a system environment variable, select Add variable string, and in the editbox below, type:
${env_var:your-environment-variable-name}/path-to-jar
. For example, if your system environment variable isMYVAR
and the JAR file is undersubdir/myfile.jar
, you should type${env_var:MYVAR}/subdir/myfile.jar
.
这篇关于如何在Eclipse启动配置中使用变量进行类路径定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!