java - 如何将属性文件中的类路径值赋予变量

标签 java spring-boot properties-file

我正在寻找一种正确的方法来为属性文件中的变量提供类路径值

logging.file=classpath:logs/server.log

这样,当我运行项目时,就会在类路径中创建文件夹名称为 log 的日志文件。

任何帮助将不胜感激。

提前致谢。

最佳答案

类路径可能包含各种文件夹(那么如何选择其中之一?)以及无法在其中创建任何内容的 jar。我想在“类路径上”创建一些东西并不是一个好主意。您最好将日志放在某个文件系统目录中:

logging.file=/some/external/directory/server.log

关于java - 如何将属性文件中的类路径值赋予变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45535142/

相关文章:

java - 语法错误: missing ] after element list in jquery

java - 仅显示 JTable 中的一列

java - Spring 启动: Best way to return 503 HttpStatus in ResponseEntity if the DataSource is DOWN

java - spring中通过@propertysource注解加载属性文件和使用PropertySourcesHolderConfigure bean加载属性文件有什么区别

java - Flowable 在 Flowable UI 上部署 flowable 应用程序

java - Firefox Webdriver 无法使用扩展启动

spring-boot - Thymeleaf 下载登录空白文件,而不是导航到 login.html (Springboot)

java - 如何解决 H2 "Error executing DDL"错误?

android - 我应该将 ical4j.properties 文件放在 Eclipse Android 项目中的什么位置?