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 系统属性?
基础教程推荐
- 控制台应用程序中的 Java 键盘输入解析 2022-01-01
- 将 Windows 证书导入 Java 2022-01-01
- Java ECDSAwithSHA256 签名长度不一致 2022-01-01
- doFilter()是在servlet的工作完成之前还是之后执行的? 2022-01-01
- 在springboot中如何给mybatis加拦截器 2023-04-29
- 将 double 转换为 Int,向下舍入 2022-01-01
- Maven:无效的目标版本:10 2022-01-01
- JPA惰性列表上的流 2022-01-01
- 在java中使用xpath和selenium解析HTML表格数据 2022-01-01
- 如何在相机中应用自定义滤镜 [Surfaceview 预览]. 2022-01-01
