[英]How to use external configuration files with Spring boot deployed in Tomcat 8.5
[英]Spring boot: How to read external files reside in Tomcat when deployed as war
我正在将 Spring 启动应用程序作为战争部署到我现有的 Tomcat 服务器。 我将写入一个 json 文件,该文件位于 Tomcat 服务器根目录的/conf/my.json
中。
我的 Spring Boot 将部署在我的 Tomcat 服务器根目录中的webapp
中,因此,假设我的 Spring Boot 应用程序名为mySpring
,它将位于/webapp/mySpring
位置。
如何在 Spring Boot 应用程序中读取my.json
?
谢谢
您可以使用 ResourceUtils 来获取文件。 File file= ResourceUtils.getFile( "classpath:conf/my.json");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.