如何解决Spring boot IoC:相同的bean定义,不同的分辨率
我使用的依赖项包含一个条件 @Configuration
类:
@Configuration
public abstract class BaseConfig {
@Bean
public ISchedulerService schedulerService() {
return new HapiSchedulerServiceImpl().setDefaultGroup(HAPI_DEFAULT_SCHEDULER_GROUP);
}
}
我需要覆盖这个 bean 定义。我正在使用 @Primary
注释:
@Configuration
public class MpiFhirConfiguration {
@Bean
@Primary
public ISchedulerService schedulerService(
@Qualifier("quartzProperties") Properties properties
) {
return new MySchedulerServiceImpl(properties);
}
}
在我的本地环境中,这个 bean 被正确覆盖。我看过_/actuator/beans
:
"schedulerService":{
"aliases":[
],"scope":"singleton","type":"cat.gencat.catsalut.hes.mpi.api.configuration.MySchedulerServiceImpl","resource":"class path resource [cat/gencat/catsalut/hes/mpi/api/configuration/MpiFhirConfiguration.class]","dependencies":[
"mpiFhirConfiguration","quartzProperties","environment","schedulerJobFactory"
]
}
但是,当我在集成环境中执行相同的代码时,我得到:
"schedulerService":{
"aliases":[
],"type":"ca.uhn.fhir.jpa.sched.HapiSchedulerServiceImpl","resource":"class path resource [cat/gencat/catsalut/hes/mpi/api/FhirserverConfigR4.class]","dependencies":[
"fhirserverConfigR4","schedulerJobFactory"
]
}
代码是一样的。
有关如何调试此行为的任何想法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。