2016-03-26 36 views
2

何らかの理由により、SpringはRepoをサービスクラスに自動配線できません。私は同様の問題を扱うすべてのSOスレッドを通過しましたが、私は問題を解決できませんでした。Spring:自動従属依存のインジェクションが失敗しました

ここは私のコードです。

public interface WProcessItemDetailsRepo extends PagingAndSortingRepository<WProcessItemDetail, Long>, JpaSpecificationExecutor<WProcessItemDetail>{ 

} 

とサービスクラス

@Service("processItemDetailsService") 
@Transactional 
public class WProcessItemDetailsService implements Serializable{ 
    /** 
    * 
    */ 
    private static final long serialVersionUID = 2395733723021028217L; 
    @Autowired 
    WProcessItemDetailsRepo detailsRepo; 

    public WProcessItemDetail save(WProcessItemDetail detail){ 
     return detailsRepo.save(detail); 

    } 
    public List<WProcessItemDetail> save(List<WProcessItemDetail> details){ 
     return (List<WProcessItemDetail>) detailsRepo.save(details); 
    } 

} 

私はプログラムを実行しようとすると、それは私はあなたがあなたのインターフェイスのための注釈を忘れてしまったと思う次のスタックトレース

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 'processItemDetailsService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: sa.tabukuni.gwsc.repo.WProcessItemDetailsRepo sa.tabukuni.gwsc.service.domain.WProcessItemDetailsService.detailsRepo; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [sa.tabukuni.gwsc.repo.WProcessItemDetailsRepo] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1204) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:538) 
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476) 
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:302) 
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:229) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:298) 
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:725) 
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757) 
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480) 
    at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:403) 
    at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:306) 
    at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:106) 
    at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4812) 
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5255) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:147) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1408) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1398) 
    at java.util.concurrent.FutureTask.run(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) 
    at java.lang.Thread.run(Unknown Source) 
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: sa.tabukuni.gwsc.repo.WProcessItemDetailsRepo sa.tabukuni.gwsc.service.domain.WProcessItemDetailsService.detailsRepo; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [sa.tabukuni.gwsc.repo.WProcessItemDetailsRepo] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:555) 
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:87) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331) 
    ... 22 more 
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [sa.tabukuni.gwsc.repo.WProcessItemDetailsRepo] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1261) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1009) 
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:904) 
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:527) 
    ... 24 more 
+1

jpaを有効にしましたか'@ EnableJpaRepositories'のリポジトリ?その場合は、設定を追加し、プロジェクト構造の詳細を追加してください。 –

+0

登録するSpringコンポーネントを取得するためにコンポーネントスキャンを定義したか、Beanを個別に定義しましたか? –

+0

私はちょうどそれを考え出しました、このプロジェクトはどこに統一された階層を使用するマルチモジュールシステムの一部です。エンジニアがコンテキストファイルを変更し、タグの 'base-package'属性の新しいパッケージを設定しました。 – Basil

答えて

1

で失敗しています:

@Repository 
public interface WProcessItemDetailsRepo extends PagingAndSortingRepository<WProcessItemDetail, Long>, JpaSpecificationExecutor<WProcessItemDetail> {} 
+0

'@Repository'はちょうどここにあります –

+0

私は春のブートを使用しているので、それは私が入力したものです。 – duffymo

+1

Springデータを使用しているときは、 '@ Repository'を使う必要はありません。 'RepositoryRestResource'を使うことは質問にも関係しません。 –

関連する問題