Reputation: 63
I am building a Kafka project in Spring and I needed to store sensitive information like access tokens within my project. So, I created a secrets.properties file inside my resources folder, added my confidential information in that file, and added the following line to my application.properties file:
spring.config.import=optional:secrets.properties
I now want to access the information stored inside the newly created secrets file inside my Java class, but am unsure how to do that. Can someone guide me on how to do this?
Thanks
Upvotes: 0
Views: 904
Reputation: 1092
You can use ClassPathResource. Assuming secrets.properties is in the src/main/resources folder ClassPathResource("secrets.properties")
.
Upvotes: 1