gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 21:54:14 25 4
gpt4 key购买 nike

我如何从 Netbeans 中使用 Tomcat,设置一个我可以使用 System.getProperty(...); 读取的环境变量

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 属性平台设置

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

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"));

关于java - Tomcat:如何在 Netbeans 中设置 Java 系统属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8577249/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com