Jpa配置加载基本bean,扫描实体并启用存储库。基于运行时的某些条件,我想添加一些要扫描的实体和存储库的包,并将它们连接到bean工厂。要扫描的额外软件包仅在运行时可用。
@Configuration
@EnableJpaRepositories
@EntityScan
@PropertySource(value = "classpath:jpa.properties")
@EnableTransactionManagement(proxyTargetClass = true)
@EnableJpaAuditing
public class JpaConfiguration {
...
...
public void condition(){
if(someCondition){
//scan more entities
//enable more repositories
}
}
}
是否可以做这样的事情?