I am implementing a third party library that uses Spring, which is declaring a Filter in the following way:
@Bean
@Autowired
public Filter filter() {
return new Filter();
}
I load the configuration class to my application with a @Import(Configuration.class). My Spring Boot application loads the Filter and seems to try to use it, but I don't want that. How can I make Spring ignore such Beans, i.e., simply don't load them (supposing the third party library can work without them)?
We followed provider recommendation/decided for:
Appropriate and edit config
Means: Copy, paste and edit the original "Configuration" instead of/before importing/scanning it:
One alternative approach is:
Destroy Bean
As described by:
How can i remove a singleton spring bean from ApplicationContext?
..., we only need to "plug it" (e.g.) simple like:
..also possible:
Replace Bean
Here we replace the Bean (by type and name), with an "NO-OP" bean:
...
Ideally
Provider would make it
@ConditionalOnXXX/bind it to@Profile! :)... (+any other alternatives)