spring - Spring Boot - 如何在扫描期间排除一个组件?
问题描述
我有一个需要使用的 JAR 依赖项。该 JAR 中有一个组件干扰了我的 Spring Boot 应用程序的一部分。我需要排除那个 ONE 组件,并且目前无法更改 JAR 依赖项中的组件定义。
我尝试了以下方法,但它不起作用,bean 仍然加载:
@SpringBootApplication
@ComponentScan(useDefaultFilters = false, excludeFilters = [Filter(type = FilterType.ASSIGNABLE_TYPE, classes = [SomeBean::class])])
bean定义为:
@RestController
class SomeBean {
注意:这些片段在 Kotlin 中。
解决方案
尝试这个
@SpringBootApplication(exclude = { SomeBean.class })
推荐阅读
- node.js - 如何访问 Heroku 的默认 MongoDB 数据库。我在没有任何 mongo 字符串的情况下上传到 Heroku
- firebase - Flutter 的 Firestore 错误代码列表
- microsoft-graph-api - 在所有用户的频道消息中搜索
- javascript - 要求 sequilize 模块在某些快速应用程序文件中返回未定义
- uno-platform - 未实现的 UIElement.FlowDirection 缺少“NotImplemented”属性
- allen-sdk - 我在哪里可以下载视觉编码实验 (allen-sdk) 的图像或视频刺激?
- php - POST 端点上的 PHPUnit 测试用例返回 400
- javascript - 如果使用 innerHTML 创建按钮将不起作用
- laravel - 我可以将模型数组转换为模型集合吗?
- nested - 错误:“非法查询语法。'/' 之前的段不是实体或复杂类型。”