【发布时间】:2015-06-01 20:31:36
【问题描述】:
我需要使用 Java 获取已部署的 Spring 应用程序的完整路径。我尝试跟随以获取路径
getClass().getProtectionDomain().getCodeSource().getLocation().getPath()
返回如下:
- 在 CentOS 上运行的 Wildfly:
"/content/MyProject.war/WEB-INF/classes"
(部分路径)
- 在 Win7 上运行 Wildfly:
"/C:/wildfly-8.2.0.Final/standalone/deployments/MyProject.war/WEB-INF/classes"
(返回完整路径)
上面在我的 Windows 机器上工作,但在 Wildfly 上运行的 CentOS 上没有工作。
【问题讨论】:
标签: java spring centos wildfly