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