在运行配置VM参数中访问eclipse类路径变量M2_REPO的值 [英] Accessing the value of eclipse classpath variable M2_REPO in run configuration VM arguments

查看:138
本文介绍了在运行配置VM参数中访问eclipse类路径变量M2_REPO的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在eclipse的运行配置中,您将获得一组可用于VM参数的默认变量,例如 container_path env_var

我想要访问的是一个类路径变量, M2_REPO ,但看不到一种方式这个。我需要在VM参数中指定一个javaagent,这需要一个jar文件的路径。这个jar文件位于maven存储库中,但是我找不到使用已经配置的$ code> M2_REPO 类路径变量指定maven仓库的路径的方式(在code>窗 - > 偏好 - > 的java - > 构建路径 - > 类路径变量)。
我想做的是将此作为我的VM参数,但不能因为 classpath_var 不是一个真正的变量。

  -javaagent:$ {classpath_var:M2_REPO} /org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar 

有没有其他方式访问VM参数中 M2_REPO 的值?

解决方案

这不是你所要求的,但它对我们来说是一种共享代码库的方式,而在我们的运行配置中没有硬编码路径。而不是使用类路径变量,请使用字符串替换变量(在 windows - > preferences - > run / debug - > String Substitution 中配置)。将其设置为与M2_REPO的值相同的路径并保存。如果您的字符串替换变量名称也是M2_REPO,则使用上述示例,VM参数将为

  -javaagent:$ {M2_REPO} /org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar 

更清楚的是,我会亲自创建一个直接打开jpa jar的openjpa_2_1_0_agent字符串替换变量。


In the run configuration of eclipse, you are provided with a set of default variables that you can use in the VM arguments, like container_path and env_var.
What I want to access is a classpath variable, M2_REPO, but can't see a way of doing this. I need to specify a javaagent in the VM arguments, which requires a path to a jar file. This jar file lives in the maven repository, but I can't find a way of specifying the path to the maven repository using the already configured M2_REPO Classpath variable (configured in windows->preferences->java->Build Path->Classpath variable).
What I would like to do is use this as my VM arguments but can't because classpath_var isn't a real variable.

-javaagent:${classpath_var:M2_REPO}/org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar

Is there any other way of accessing the value of M2_REPO in VM arguments?

解决方案

This isn't exactly what you asked for, but it worked for us as a way of sharing a codebase and not having hard coded paths in our run configurations. Rather than using a classpath variable, use a string substitution variable (configured in windows -> preferences -> run/debug -> String Substitution). Set it to the same path as the value of M2_REPO and save. Using the above example if your string substitution variable name was also M2_REPO, the VM Argument would be

-javaagent:${M2_REPO}/org/apache/openjpa/openjpa/2.1.0/openjpa-2.1.0.jar

To be even more clear, I would personally just create an openjpa_2_1_0_agent string substitution variable that went directly to your open jpa jar.

这篇关于在运行配置VM参数中访问eclipse类路径变量M2_REPO的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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