봄 부팅을 Gemfire를 사용하여 아래: 나는 POC에 대한 스프링 부팅을 Gemfire을 사용하고
Error creating bean with name 'application': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'Product': Cannot create inner bean 'org.emc.smartpoc.util.ProductDBLoader#2564575' of type [org.emc.smartpoc.util.ProductDBLoader] while setting bean property 'cacheLoader'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.emc.smartpoc.util.ProductDBLoader#2564575': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.emc.smartpoc.service.ProductRepository org.emc.smartpoc.util.ProductDBLoader.productRepository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'productRepository': Invocation of init method failed; nested exception is java.lang.IllegalStateException: No region 'Product' found for domain class class org.emc.smartpoc.domain.Product! Make sure you have configured a Gemfire region of that name in your application context!
at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:308)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:475)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:304)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:300)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:195)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:703)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:760)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:482)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:683)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:313)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:944)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:933)
at org.emc.smartpoc.Application.main(Application.java:44)
같은 예외를 가져 오는 동안 자원 종속성 주입 실패 내 캐시 구성 파일은 다음과 같습니다 :
<util:properties id="gemfire-props">
<prop key="log-level">warning</prop>
</util:properties>
<gfe:cache properties-ref="gemfire-props"/>
<gfe:replicated-region id="Product">
<gfe:cache-listener>
<bean class="org.emc.smartpoc.util.LoggingCacheListener"/>
</gfe:cache-listener>
<gfe:cache-loader>
<bean class="org.emc.smartpoc.util.ProductDBLoader"/>
</gfe:cache-loader>
<gfe:cache-writer>
<bean class="org.emc.smartpoc.util.ProductDBWriter"/>
</gfe:cache-writer>
</gfe:replicated-region>
@Configuration
@ImportResource("/cache-config.xml")
@ComponentScan(basePackages={"org.emc.smartpoc"})
@EnableAutoConfiguration
@EnableGemfireRepositories(basePackages="org.emc.smartpoc.service")
@EnableTransactionManagement
public class Application implements CommandLineRunner {
@Resource(name="Product")
private Region<Long,Product> region;
@Autowired
private ProductRepository productRepository;
private static Log log = LogFactory.getLog(Application.class);
public static void main(final String[] args) throws InterruptedException {
SpringApplication.run(Application.class, args);
}
/* (non-Javadoc)
* @see org.springframework.boot.CommandLineRunner#run(java.lang.String[])
*/
@Override
public void run(String... args) throws Exception {
// TODO Auto-generated method stub
for (long i = 1; i<=3; i++){
Product p = this.region.get(i);
log.debug("Retrieved product " + p.getName() + " from cache");
}
//Let's try this again
log.debug("2nd pass...This time the CacheLoader is not called since items are already cached");
for (long i = 1; i<=3; i++){
Product p = this.region.get(i);
log.debug("Retrieved product " + p.getName() + " from cache");
}
//Create a new product
log.debug("Adding a new product to the cache...");
Product iphone = new Product(4L, "Apple IPhone", new BigDecimal(299.99),"Smart phone");
this.region.put(iphone.getId(), iphone);
while (this.productRepository.count() == 3) {
log.debug("Product repository still has : " + productRepository.count() + " rows");
Thread.sleep(10);
}
log.debug("Product repository now has : " + productRepository.count() + " rows");
log.debug("Removing a product from the cache...");
this.region.destroy(4L);
while (this.productRepository.count() == 4) {
log.debug("Product repository still has : " + productRepository.count() + " rows");
Thread.sleep(10);
}
log.debug("Product repository now has : " + productRepository.count() + " rows");
}
}
그리고 @Component와 @Configuration과 ProductDBLoader, ProductDBWriter을 주석 한 :
내 Application.Java 콘텐츠 아래에 있습니다.
이 문제를 해결하는 데 도움을주십시오.
오류 메시지를 읽었습니까? GemFire 영역이 구성되어 있지 않습니다. – chrylis
캐시 구성 파일 –