简体   繁体   English

如何在Glassfish 2.1中设置env变量

[英]How to set an env variable in Glassfish 2.1

I want to deploy an application, that is currently deployed in Tomcat, in Glassfish version 2.1. 我想在Glassfish 2.1版中部署当前部署在Tomcat中的应用程序。

In the Tomcat server.xml I have an env variable defined in the server.xml that is used by the application 在Tomcat server.xml中,我在server.xml中定义了一个由应用程序使用的env变量

  <Environment name="CTClassFolder" type="java.lang.String" value="C:\TMP" />

How do I set this variable in Glassfish 2.1. 如何在Glassfish 2.1中设置此变量。 I know there is an asenv.conf file in version 3, but I dont find anything like that in 2.1. 我知道版本3中有一个asenv.conf文件,但我在2.1中找不到类似的东西。

g051051's answer is still valid in GF4/Payara : g051051的答案在GF4 / Payara中仍然有效:

In the admin console ( http://localhost:4848 ), navigate to : 在管理控制台( http:// localhost:4848 )中,导航至:

-Configuration
    -server-config
        -JVM Parameters
            -JVM Options

Then, add your parameter prefixed with -D, for instance : 然后,添加前缀为-D的参数,例如:

-DBF_DIR_DOC=C:/BU/BF/BFdocuments

In your java code, you can retrieve the property easily : 在您的Java代码中,您可以轻松地检索属性:

String directory = System.getProperty("BF_DIR_DOC");

You're done. 你完成了。

打开服务器,登录管理控制台,导航到JVM选项,添加-D参数,然后重新启动。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM