yılında depo autowire olamaz. Bir çözüm bulamadığım için org.springframework.data.repository.query.QueryByExampleExecutor class not found
hatasını alıyorum. Ben alıyorumBen bahar ek açıklama kullanarak denetleyici içinde depoyu autowire çalışıyorum bahar
Hata:
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'articleController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.payforeign.article.ArticleRepository com.payforeign.article.ArticleController.repository; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'articleRepository': Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/data/repository/query/QueryByExampleExecutor
Denetleyici ben @Repository
ile depo açıklamalı gelmiş
package com.payforeign.article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
@RequestMapping("/service")
public class ArticleController {
@Autowired
private ArticleRepository repository;
//controller methods
}
Depo. İlkbahar belgelerine göre sadece depo arayüzüne sahibim. Doğru mu?
package com.payforeign.article;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ArticleRepository extends CrudRepository<Article, Long> {}
applicationContext.xml
Ben base-package
ve component-scan
doğru ile jpa:repositories
dahil ettik. Bunun ek açıklama (<mvc:annotation-driven /> <tx:annotation-driven />
) olduğunu belirttim ve JDBC ve JPA ayarlarını ekledim. Benim applicationContext.xml doğru
<context:annotation-config/>
Yığın izi açık: SINIFINIZDAN KAYNAKLANAN YARIM VERİ JAR'ları eksik. – duffymo
'NoClassDefFoundError' neredeyse her zaman bir sürüm uyuşmazlığı anlamına gelir. Bu durumda, örnek olarak sorgulamak için RC sürümlerine (veya en azından en son sürüm sürümlerine) ihtiyacınız olduğuna inanıyorum. – chrylis
"Spring-data-Commons" ı 1.11.4'den 1.12.1 sürümüne yükselttim ve sorunu çözdüm. Teşekkürler @chrylis – Black