1

I have 2 spring configuration files in my application(application.properties and custom-application.properties.) Each property file contains some of the configuration properties. I just wanted to log all the properties which are loaded.

How to print properties loaded for the profile?

Hari
  • 89
  • 1
  • 2
  • 9
  • 1
    Possible duplicate, already answered here https://stackoverflow.com/questions/8298344/printing-all-properties-set-via-spring-propertyplaceholderconfigurer – trisek Sep 23 '19 at 12:15
  • I want to print all active attributes present in both application.properties and custom-application.properties – Hari Sep 23 '19 at 13:09
  • I don't know if this will fit your needs, but you can see on this [link](https://gist.github.com/sandor-nemeth/f6d2899b714e017266cb9cce66bc719d) if this is what you want to achieve. – trisek Sep 23 '19 at 13:56
  • I don't know whether that program will print all properties from application.properties and custom-application.properties. Then How do I call java file in my program for testing purpose? – Hari Sep 23 '19 at 14:50
  • If you start your application with custom profile, yes, it will print all properties from application and custom-application.properties. And can you explain a little bit more, what kind of java file you want to call in your program? – trisek Sep 23 '19 at 20:19
  • Suppose as you mentioned before, https://gist.github.com/sandor-nemeth/f6d2899b714e017266cb9cce66bc719d how do I use this class in my project? Is it like create class and put the content their or does it require any configuration? – Hari Sep 24 '19 at 09:40
  • You can just create a class and put the content from this github link. Because you are using spring boot, everything will work out of the box. So when you start your application with default profile, only properties from `application.properties` file will be shown, and if you start the application with custom profile, then both properties from `application.properties` and `custom-application.properties` will be printed in the console. – trisek Sep 24 '19 at 09:49
  • Suppose if we have some place holders like `producers.bootstrap.server.config=${kafka.list} ` `kafka.list=promotpp1.aws.et.com:19373,promotpp2.aws.et.com:19373,promotapp3.aws.et.com:19373` and I am getting error like `java.lang.IllegalArgumentException: Could not resolve placeholder 'kafka.list' in value "${kafka.list}"` – Hari Sep 24 '19 at 10:19

0 Answers0