spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.95k stars 40.65k forks source link

Provide a mechanism to hide properties in the metadata #2421

Open wilkinsona opened 9 years ago

wilkinsona commented 9 years ago

2027 adds support for configuring Bitronix and Atomikos' connection pools via the environment. These pools expose some properties that it doesn't make sense to expose to the environment such as PoolDataSourceBean.failed. We also want to hide PoolDataSource.className as we configure that automatically to use our DirectXADataSource

snicoll commented 9 years ago

We need a way to also disable keys that are set in code that we don't own. Some thoughts:

We could also add an "ignore" attribute to a property to make explicit that it should be ignored (in case of IDEs are trying to do smart things behind our back). In this case, we could ignore any property by simply registering with the ignore flag enabled; when we merge the additional meta-data with the current result, we override the flag.

philwebb commented 9 years ago

Since this is quite an edge-case I think a new annotation might be better. I'm worried that more attributes on @ConfigurationProperties might be confusing. We already have @NestedConfigurationProperty so perhaps something like @IgnoredConfigurationProperty which could be used on the class or a field.

Another option might be to try and extend the additional-spring-configuration-metadata file.

wilkinsona commented 3 months ago

This has come up again in 3.4 when some changes in Oracle UCP have resulted in some new properties appearing in the metadata:

  1. spring.datasource.oracleucp.connection-wait-duration
  2. spring.datasource.oracleucp.connection-wait-duration-in-millis
  3. spring.datasource.oracleucp.hostname-resolver

We don't need both 1 and 2. 3 doesn't make sense at all as it requires an instance of HostnameResolver which can't be created from properties (without custom conversion).

philwebb commented 2 months ago

We discussed this today and we'd like to configure this in an external file (similar to additional-spring-configuration-metadata). This would remove the need for any new public annotations. We'd keep the binder as it is and not try to prevent binding if someone did use an excluded name.