I am attempting to migrate a spring, non-boot, app to a boot app. The current one builds a war file. Following these instructions, I am walking through the steps to migrate.
I am finding that the @SpringBootApplication annotation forces a lot of things to fail. For instance, it tries to auto config security when I really need the existing xml security config to remain as is. I found that I can override @EnableAutoConfiguration and exclude configuration classes (.i.e. SecurityAutoConfiguration.class). But I am finding it is doing this a great deal for the items I already have on my classpath. I decided it would be better to remove @SpringBootApplication and replace it with just @Configuration, @ComponentScan and @ImportResource to load my original context xml. The class extends SpringBootServletInitializer so that I can register my custom servlets and filters.
What I have found, it now no longer knows to load the application.yml or bootstrap.yml. What triggers auto configuration of these files? Do I fall back to loading with the traditional properties placeholder configurers? I want to avoid this as the next step is to hook it up to spring cloud config to centralize the management of the application configuration.
@SpringBootApplication
is a alternative for @Configuration
, @EnableAutoConfiguration
and @ComponentScan
.
Probably you want use @Configuration
+ @ComponentScan
. If you want load xml configuration you can use: @ImportResource
annotation.
If you want use autoconfiguration, but you can disable a few auto configurations, eg:
@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})
Details:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With