假设我有@Configuration
类,该类有条件地使用RestClient
注册了@ConditionalOnProperty
类型的bean。
@Configuration
public class RestClientConfig {
@Bean("restClient")
@ConditionalOnProperty(prefix = "rest.client", name = "enabled", havingValue = "false", matchIfMissing = true)
public RestClient restClient(RestProperties properties) {
return new HttpRestClient(...);
}
@Bean("restClient")
@ConditionalOnProperty(prefix = "rest.client", name = "enabled", havingValue = "true")
public RestClient mockRestClient(RestProperties properties) {
return new MockRestClient();
}
}
当我运行此应用程序时,一切正常。当我在另一个bean中自动装配RestClient
时,正确选择了给定类型的实现。
但是,当我在Intellij IDEA中查看此设置时,它报告:
是否可以指示Intellij了解@ConditionalOnProperty
或在Spring Boot中以其他方式进行操作?