在Eclipse项目中设置环境变量 [英] Setting environment variables in eclipse project

查看:796
本文介绍了在Eclipse项目中设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在文件中放置了一组环境变量,我想在通过Eclipse启动项目时进行设置.

I have a set of environment variables placed in a file, which I want to set when my project is launched via Eclipse.

我知道我们可以在运行配置中设置环境变量,但是必须手动设置每个变量.有没有办法可以从文件中设置这些变量?

I understand that we can set environment variables in run configuration, but there each variable has to be set manually. Is there a way through which I can set these variables from a file?

推荐答案

您可以在属性文件(例如config.properties)中添加所有文件和文件夹路径,然后通过以下方式在testsetup方法中使用它:

You can add all file and folder paths inside the properties file (example config.properties) and then used it inside the testsetup method by

InputStream input = new FileInputStream("Path to//config.properties");
                Properties prop = new Properties();
                prop.load(input);
                System.setProperty("log4j2.configurationFile", prop.getProperty("log4j.path"));

这样,可以从外部修改所有文件/文件夹路径,而无需在项目内部设置环境变量.

this way, all files/folder paths can be modifies from outside and there's no need to set environment variable from inside the project.

这篇关于在Eclipse项目中设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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