When upgrading libraries, I would like our applications to be more strict about property names they configure. When old properties are used, I would rather not to start the application and let developers fix them first.

PropertiesMigrationListener from spring-boot-propertries-migrator provides pretty much what I want to do if there are options to change its behavior slightly. Currently, it reports and replaces deprecated/removed properties, and keeps starting the application.

Instead, I would like to have following flags(properties) to modify its behavior: - Do not replace the properties - After logging, prevent starting application(throw an exception)

If such flags are available, applications can be set to more strict mode about properties they use.

Comment From: philwebb

I'm not quite sure how we'd configure it. We could perhaps use a property, but then the users would need to remember to set that property to trigger the strict behavior.

Comment From: philwebb

See also #10030

Comment From: ttddyy

I was thinking properties such as spring.migration.strict=true.

If I need to enforce this behavior from library to applications, I might write a listener that listens ApplicationEnvironmentPreparedEvent and set the property to environment. So that all applications using my library will be enforced on this strict behavior.

Another approach I thought was to post process PropertiesMigrationListener bean reflectively to check whether there are warn/error reports; then, stop starting application if there are errors. But, it seems like listeners registered via spring.factories are not part of the beans. So, I don't have access to the actual instance of PropertiesMigrationListener. (Might be another improvement request to register ApplicationListener created via spring.factories to application context as beans)

Comment From: wilkinsona

We've discussed today and feel that validation-like behaviour isn't appropriate for the migration module. We do hope to implement validation in the future and that is being tracked by #10300. In the meantime, if you are interested in validation that meets your specific needs we recommend using the migration listener's code as inspiration to create your own module.

Comment From: ttddyy

For those who are interested, I wrote an application listener that checks the usage of deprecated properties, using code from spring-boot-properties-migrator.

https://gist.github.com/ttddyy/ec22d32a20ed8385a478f2657e8aee4a