This question already has an answer here:
How to set JVM arguments in tomcat that work both in eclipse and using the startup.bat
                                
                                    (1个答案)
                                
                        
                                去年关闭。
            
                    
请帮助您了解如何在Tomcat服务器v9上设置系统属性。因此,只要需要属性值,就可以在Java代码中使用System.getProperty(“ home”)来访问它们。我正在使用Eclipse

我尝试在catelina.bat中设置JAVA_OPTS,但代码中为null。

这是我的catelina.bat:

  rem Do this here so custom URL handles (specifically 'war:...') can be used in the security policy
set "JAVA_OPTS=%JAVA_OPTS% -Djava.protocol.handler.pkgs=org.apache.catalina.webresources"
set "JAVA_OPTS=%$JAVA_OPTS% -Dhome=\Users\Ayush\Documents\apache-tomcat-9.0.7"
set "JAVA_OPTS=%JAVA_OPTS% --add-modules java.se.ee"


我需要在代码中使用房屋财产。

提前致谢。

最佳答案

在服务器选项卡中,双击tomcat服务器->单击打开启动配置->单击(x)=参数

在VMarguments中添加以下内容:

-Dhome="\Users\Ayush\Documents\apache-tomcat-9.0.7"

关于java - 在Eclipse中设置系统属性,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49873197/

10-11 20:38
查看更多