我可以在同一个Spring Boot应用程序中有两个@ClientCacheApplication吗?

问题描述 投票:0回答:1

我可以在同一个Spring Boot应用程序中有两个@ClientCacheApplication实例吗?

我有两个班:PeopleDataAccessJobDataAccess。他们两个都是@ClientCacheApplication

@Service
@ClientCacheApplication(name = "AccessingDataGemFireApplication", logLevel = "error")
@EnableEntityDefinedRegions(basePackageClasses = People.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireRepositories(basePackageClasses = PeopleRepository.class)
public class PeopleDataAccess {

  @Autowired
  PeopleRepository peopleRepository;

  public void saveRecord() {
    People alice = new People("Adult Alice", 40);
    People bob = new People("Baby Bob", 1);
    People carol = new People("Teen Carol", 13);
    peopleRepository.save(alice);
    peopleRepository.save(bob);
    peopleRepository.save(carol);
  }
}


@Service
@ClientCacheApplication(name = "AccessingDataGemFireApplication", logLevel = "error")
@EnableEntityDefinedRegions(basePackageClasses = Job.class, clientRegionShortcut = ClientRegionShortcut.LOCAL)
@EnableGemfireRepositories(basePackageClasses = JobRepository.class)
public class JobDataAccess {

  @Autowired
  JobRepository jobRepository;

  public void saveRecord() {
    Job firemen = new Job("Firemen");
    Job accounting = new Job("Accounting");
    jobRepository.save(firemen);
    jobRepository.save(accounting);
  }
}
gemfire spring-data-gemfire
1个回答
1
投票

简短回答......不。使用Pivotal GemFire / Apache Geode,任何缓存实例(无论是ClientCache还是对等Cache(使用过的服务器端))都是Singleton。也就是说,每个JVM只能有1个实例。

也许如果你描述你的UC以及你想要实现的目标,我可以提供更多指导?

© www.soinside.com 2019 - 2024. All rights reserved.