In java code life, we wrote so many common property in constant class or interface or property file. In my Project I store common properties in application.properties and by using spring Environment object I accessed in my code.
So my question:
Is it good way store all common string in applications.properties file?
Or any other best way to store common properties?
Example: My property file looks like this:
# 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
So logger information is good to write in properties file but like formats or write excel information which are common / contacts strings.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.