Tomcat: How do I set up a Java system property in Netbeans?(Tomcat:如何在 Netbeans 中设置 Java 系统属性?)
问题描述
我如何从 Netbeans 中为 Tomcat 设置一个我可以使用 System.getProperty(...);
How do I, from Netbeans, for use with Tomcat, set up an environment variable that I can read using System.getProperty(...);
我们有一个源代码控制项目 - 我们不断对我们愿意"分享的确认进行更改(不想使用 svn:ignore).我们正在尝试设置一个简单的参数,即应用程序配置属性的环境变量.例如:mark.properties 或 john.properties.如果系统找不到环境变量,则默认为 server.properties(用于实时系统).
We have a source controlled project - and we're constantly making changes to confirurations that we "would" like to share (don't want to use svn:ignore). We're trying to set up one simple parameter, an environment variable to the config properties of our application. For example: mark.properties or john.properties. If the system can't find the environment variable, then it defaults to server.properties (for the live system).
推荐答案
1.转到 Tomcat 属性平台设置
在 Netbeans 中,单击服务"标签.在服务器"下,您将看到Tomcat 7.0".右键单击Tomcat 7.0"并选择属性".然后选择平台"选项卡.
In Netbeans, click the "Services" tag. Under "Servers", you'll see "Tomcat 7.0". Right click "Tomcat 7.0" and select "Properties". Then select the "Platform" tab.
<强>2.在 VM 选项下,添加 -Dvariable=value
将 D 保留在原位,并用您想要设置的任何变量名称替换该变量,并为您想要设置该变量的任何值赋值.
Leave the D in place, and replace the variable with whatever variable name you'd like to set and value whatever value you'd like to set the variable to.
3.从您的代码中读出属性.
System.out.println("The value is " + System.getProperty("variable"));
这篇关于Tomcat:如何在 Netbeans 中设置 Java 系统属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Tomcat:如何在 Netbeans 中设置 Java 系统属性?
- C++ 和 Java 进程之间的共享内存 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01