0

I have written a custom processor app to read data from MongoDB. In this app, I use MongoTemplate for MongoDB operation, so SpringBoot has provide the MongoProperties class for properties loading.

However, when I try to white list MongoProperties so that I can see these properties on WebUI dashboard, I encounter some problem. It just shows "No properties avaliable".

I have followed the 23.1 Whitelisting application properties in the document to add the following line in spring-configuration-metadata-whitelist.properties file

configuration-properties.classes=org.springframework.boot.autoconfigure.mongo.MongoProperties

And add the following dependency in pom.xml

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-configuration-processor</artifactId>
        <optional>true</optional>
    </dependency>    

I have read the code of spring-cloud-stream-app-starters/mongodb on github. It seems that it does the same with me.

Actually, I have written several other apps, and the WebUI shows the white-listed properties normally. The only difference is that, in these apps, I create my own @ConfigurationProperty class.

May I ask, what else should I do to white list the spring boot provided @ConfigurationProperty class(in my case, MongoProperties)?

Thank you very much for any advice!

JavyZheng
  • 53
  • 7
  • finally, it turned out to be SCDF version issue. This problem appeared on SCDF on YARN 1.0.2.RELEASE and disappeared on SCDF Local 1.1.3.RELEASE – JavyZheng Mar 21 '17 at 10:35

1 Answers1

1

An easier way to debug this is to unpack your application jar file and verify if you have :

META-INF/spring-configuration-metadata-whitelist.properties META-INF/spring-configuration-metadata.json

in your classpath (usually via app starter jar) and the spring-configuration-metadata-whitelist.properties has the entries for the required properties

Ilayaperumal Gopinathan
  • 4,099
  • 1
  • 13
  • 12
  • thanks, Ilayaperumal, I have the META-INF/*.properties file but do not have the META-INF/*.json file – JavyZheng Mar 15 '17 at 06:24
  • I have done further test by add a self-defined **@ConfigurationProperty** class, and **META-INF/spring-configuration-metadata.json** is generated. It seems that `spring-boot-configuration-processor` only generate meta data for self defined @ConfigurationProperty class but not for that in dependency library – JavyZheng Mar 15 '17 at 07:59
  • It shouldn't matter if the `.json` file is directly in your uber-jar, or embedded in a (boot provided) jar that itself is in your uber-jar. If you can confirm that indeed this is the case, then your problem comes from something else (typo in class name?, in key name?, in file name?). If the sources of your app are publicly available, then please point to them we may be able to reproduce – ebottard Mar 16 '17 at 09:04
  • @ebottard Thanks for your advice. I have double checked the file name, key name and class name(actually, I copied the config file from another project). The source is available at [scdf-read-mongo-processor](https://github.com/javyzheng/scdf-read-mongo-processor) and I will appreciate it if you could give more advice on the usage. My SCDF server is 1.0.2.RELEASE on YARN – JavyZheng Mar 19 '17 at 09:18
  • I tried it (with current version) and it worked like a charm. Could you try with a newer version of SCDF? There were changes related to supporting boot 1.4+ in SCDF 1.1.x – ebottard Mar 20 '17 at 10:08
  • @ebottard Thank you very much! It may be related to SCDF version. I think I have to study the possibility of reinstalling SCDF server. Thanks again! – JavyZheng Mar 21 '17 at 04:18
  • I also tried it with SCDF local server 1.1.3.RELEASE, and it worked, so I can confirm now this is a version problem. Thank your both for the help! – JavyZheng Mar 21 '17 at 10:31