[英]what is the best way to store common strings (properties file / constants class) in Java Spring boot Project?
在 java 代码寿命中,我们在常量 class 或接口或属性文件中写入了许多公共属性。 在我的项目中,我将公共属性存储在 application.properties 中,并使用 spring 环境 object 我在我的代码中访问。
所以我的问题:
将所有常见字符串存储在 applications.properties 文件中是一种好方法吗?
或者任何其他存储公共属性的最佳方式?
示例:我的属性文件如下所示:
# logging level
logging.level.org.springframework=ERROR
logging.level.com.mkyong=INFO
# output to a file
#logging.file.name=app.log
# temp folder example
logging.file.path==D:/Vijay/log/app.log
logging.pattern.file=%d %p %c{1.} [%t] %m%n
#logging.pattern.console=%d{HH:mm:ss.SSS} [%t] %-5level %logger{36} - %msg%n
logging.pattern.console=%d{dd-MMM-YYYY HH:mm:ss.SSS} [%t] %-5level %logger{36}:%L - %msg%n
## if no active profile, default is 'default'
spring.profiles.active=default
# root level
#logging.level.=INFO
#Formats
dubai.date.format = yyyy-MM-dd hh:mm:ss a
dubai.zone = GMT+4
last.trade.date.format = yyyyMMdd
#Write excel information
excel.filename = Bid_Ask_Summary
excel.file.date.format = dd-MMM-yy
sheet.one.name = Archieve Range
sheet.two.name = Contract Summary
file.extension = .xlsx
所以记录器信息最好写在属性文件中,但喜欢格式或写 excel 信息,这是常见的/联系人字符串。
Generally all constants/string values which are fixed will go under util package as Constants.java or {app_name}Constants.java and from there you can have static import wherever you want to use it.
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.