Tomcat:如何在 Netbeans 中设置 Java 系统属性?

2023-07-14Java开发问题
2

本文介绍了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 系统属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

如何使用 JAVA 向 COM PORT 发送数据?
How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)...
2024-08-25 Java开发问题
21

如何使报表页面方向更改为“rtl"?
How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)...
2024-08-25 Java开发问题
19

在 Eclipse 项目中使用西里尔文 .properties 文件
Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)...
2024-08-25 Java开发问题
18

有没有办法在 Java 中检测 RTL 语言?
Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)...
2024-08-25 Java开发问题
11

如何在 Java 中从 DB 加载资源包消息?
How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)...
2024-08-25 Java开发问题
13

如何更改 Java 中的默认语言环境设置以使其保持一致?
How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)...
2024-08-25 Java开发问题
13