如何在Eclipse启动配置中使用变量进行类路径定义? [英] How to use variables for classpath definition in Eclipse launch configurations?

查看:554
本文介绍了如何在Eclipse启动配置中使用变量进行类路径定义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我们的项目中,我们使用受版本控制的Eclipse启动配置与所有开发人员共享。现在有必要将外部存档包含在启动配置文件的类路径中。幸运的是,所需的存档位于每个开发人员的本地Maven存储库中。



我已经发现有一个名为 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="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;&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&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;"/>
    ...
</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 is MYVAR and the JAR file is under subdir/myfile.jar, you should type ${env_var:MYVAR}/subdir/myfile.jar.

这篇关于如何在Eclipse启动配置中使用变量进行类路径定义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆