SpringBootApplication exclude when ComponentScanning other @SpringBootApplications

后端 未结 2 746
清酒与你
清酒与你 2020-12-18 09:09

I\'m having some difficulty preventing Spring Boot from auto configuring some classes (in this example: SolrAutoConfiguration). To illustrate I\'ve setup a much reduced exam

相关标签:
2条回答
  • 2020-12-18 09:25

    Currently I think it's not possible. The issues gh-2939 and gh-2435 relate to exactly this problem.

    0 讨论(0)
  • 2020-12-18 09:33

    Spring Boot 1.3.0.M3 introduced functionality to exclude autoconfiguration using properties: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-1.3.0-M3-Release-Notes

    spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.solr.SolrAutoConfiguration
    

    Note that it should say spring.autoconfigure.exclude, not excludes as in the release notes.

    This helps prevent Spring Boot from loading autoconfig classes in the presence of multiple @EnableAutoConfiguration/@SpringBootApplication annotations.

    0 讨论(0)
提交回复
热议问题