Spring Boot version: 2.1.8.RELEASE

When using a class imported from a dependency as a @ConfigurationProperties, the generated configuration properties meta-data does not contains the description for this class' properties.

Scenario to reproduce: I test the example described in the documentation to create two data sources : https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html#howto-two-datasources.

The produced spring-configuration-metadata.json does not include the description for the properties of DataSourceProperties class.

Here is a sample of the produced meta-data:

{
   "name": "app.datasource.first.name",
   "type": "java.lang.String",
   "sourceType": "org.springframework.boot.autoconfigure.jdbc.DataSourceProperties"
},

Sample project: demo.zip

Comment From: snicoll

This is working as expected I am afraid. If the source code of DataSourceProperties is not available, we can't extract the documentation and default value as the annotation processor doesn't have access to the source model.

However, I can see how that's annoying and how the doc example is misleading. Flagging for team attention.

Comment From: jjoslet

Since this is an annotation processor, this is hard to retrieve the JavaDoc from a compiled class.

I think this pattern can have a different behavior for the computation of the default value too.

Have you planned another way to produce the description which does not suffer from this limitation ?

Maybe another annotation that is used to describe the property ?

Comment From: snicoll

@jjoslet I think I wrote exactly that in my previous comment, didn't I? We haven't scheduled anything at this point but I'd like to discuss it a bit more which is why I've flagged it.

Comment From: wilkinsona

We may be able to find the existing metadata that was generated for DataSourceProperties from the classpath and splice it into the metadata that is being generated.

Comment From: jjoslet

That will solve the issue for the particular DataSourceProperties example since it already produces meta-data. But it'll not handle the case where a third party class is not originally annotated with @ConfigurationProperties and is used in an application with @ConfigurationProperties.

Example in Spring Boot: HikariDataSource, org.apache.tomcat.jdbc.pool.DataSource. org.apache.commons.dbcp2.BasicDataSource, etc.

Comment From: snicoll

We have metadata for that too. Ssl is more what you meant and we'll have to figure out how we can update the annotation processor to handle it. I think the issue is well understood, we now need to design it.

Comment From: jjoslet

Yes, metadata are present but they miss the description.

  • Apache Commons JDBC source: https://github.com/apache/commons-dbcp/blob/master/src/main/java/org/apache/commons/dbcp2/BasicDataSource.java#L299-L302
  • spring-configuration-metadata.json from spring-boot-autoconfigure-2.1.8.RELEASE.jar:
{
  "name": "spring.datasource.dbcp2.username",
  "type": "java.lang.String",
  "sourceType": "org.apache.commons.dbcp2.BasicDataSource"
}

Comment From: snicoll

It's a third party type, they don't have description as it's not a @ConfigurationProperties type to begin with.

Comment From: cachescrubber

Since #19500 is closed: My use-case is not to generate metadata for external 3rd-party classes outside my control. I am the maintainer of the jar providing the @ConfigurationProperty type and would cooperate in providing the required metadata - for example by using annotations instead of JavaDoc or by means of manually publishing the required metadata within my jar.

Comment From: snicoll

I got that. Generating the metadata and reusing it is covered here too.

Comment From: wilkinsona

34210 is related to this. It proposed allowing the configuration processor to consume multiple additional metadata files.