Repository navigation
Description
Auto-configuration Registration
If you have created your own auto-configurations, you should move the registration from spring.factories to a new file named META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports. Each line contains the fully qualified name of the auto-configuration. See the included auto-configurations for an example.For backwards compatibility, entries in spring.factories will still be honored.
So:
- Any
src/main/resources/META-INF/spring.factoriesfile should move toMETA-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports - the comma separate value for key
org.springframework.boot.autoconfigure.EnableAutoConfigurationshould be split across separate lines.
New @autoConfiguration Annotation
A new @autoConfiguration annotation has been introduced. It should be used to annotate top-level auto-configuration classes that are listed in the new META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports file, replacing @configuration. Configuration classes that are nested within or imported by an @autoConfiguration class should continue to use @configuration as before.For your convenience, @autoConfiguration also supports auto-configuration ordering via the after, afterNames, before and beforeNames attributes. This can be used as a replacement for @AutoConfigureAfter and @AutoConfigureBefore.
So:
- Replace usage of
@Configurationwith@AutoConfigurationwhere classes are mentioned in the above replacedsrc/main/resources/META-INF/spring.factories
Test Slice Configuration
If you have created your own test-slices, you should move the registration from spring.factories to the new place under META-INF/spring/.imports. The format is the same as the new file described in the "Auto-configuration Registration" section, see above.
Above steps are complicated even more for users defining their own test slices, requiring a different filename with the same one class per line structure as above.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
timtebeek commentedon Jun 2, 2022
I'd guess somewhat lower priority as compared to other issues, as own auto configuration classes are not as often used. Typically only in company/team wide starter libraries. But still, changes like these could go unnoticed in a migration, until they break at a later date, since backwards compatibility is still there.
pway99 commentedon Jun 6, 2022
Thanks @timtebeek,
Now that unsupported file types are represented as Quarks its possible to detect and rename the file, unfortunately, it's not possible to modify Quark source contents. Perhaps this recipe could add a SearchMarker to the project pom with a message providing transformation instructions.
jkuipers commentedon Sep 23, 2022
Note that this isn't quite correct:
That spring.factories file can contain other entries besides autoconfiguration, so only when moving that entry would leave an empty file should you remove it: otherwise it should be left in place with just that entry removed.
timtebeek commentedon Sep 26, 2022
As discussed, this is already covered in Spring Boot Migrator. Might already resolve this issue here, unless we want to pull that up into Rewrite-Spring.
Add License. Fixes #197