有几天我试图解决这个问题 . 我被困了,我不知道我做错了请建议我 .

Ce实体

/**
 * The persistent class for the CE database table.
 * 
 */

@Entity
@NamedQuery(name="Ce.findAll", query="SELECT c FROM Ce c")
public class Ce implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @Column(name="ID_CE")
    private int idCe;

    @Column(name="LIB_CE")
    private String libCe;

    @Column(name="MODE_SIDRE")
    private String modeSidre;

    @Column(name="CE_SUPPORT")
    private String ceSupport;

    //bi-directional many-to-one association to GMR
    @OneToMany (fetch = FetchType.EAGER, mappedBy ="ce")
    @JsonManagedReference
    private List<Gmr> gmrs = new ArrayList<>();


    /*
    //bi-directional many-to-one association to Site
        @OneToMany (fetch = FetchType.EAGER, mappedBy ="gmr")
        @JsonManagedReference
        private List<Site> sites = new ArrayList<>(); */


    public Ce() {

    }

    public int getIdCe() {
        return this.idCe;
    }

    public void setIdCe(int idCe) {
        this.idCe = idCe;
    }

    public String getLibCe() {
        return this.libCe;
    }

    public void setLibCe(String libCe) {
        this.libCe = libCe;
    }

    public String getModeSidre() {
        return this.modeSidre;
    }

    public void setModeSidre(String modeSidre) {
        this.modeSidre = modeSidre;
    }

    public String getCeSupport() {
        return this.ceSupport;
    }

    public void setCeSupport(String ceSupport) {
        this.ceSupport = ceSupport;
    }



    public List<Gmr> getGmrs() {
        return this.gmrs;
    }

    public void setGmrs(List<Gmr> gmrs) {
        this.gmrs = gmrs;
    }

    public Gmr addGmr(Gmr gmr) {
        getGmrs().add(gmr);
        gmr.setCe(this);

        return gmr;
    }

    public Gmr removeGmr(Gmr gmr) {
        getGmrs().remove(gmr);
        gmr.setCe(null);

        return gmr;
    }

}

CE DAO

包fr.rte_france.caqui.dao;

import fr.rte_france.caqui.entity.Ce;
@Transactional(propagation=Propagation.REQUIRED)
@Repository
public interface CeDao extends JpaRepository<Ce, Integer>{

}

Ce Service&Impl

package fr.rte_france.caqui.service;

import fr.rte_france.caqui.entity.Ce;

public interface GererCe {
    public Ce getCe(int id);

}


package fr.rte_france.caqui.service.impl;

@Service
@Transactional
public class GererCeImpl implements GererCe{


    @Autowired
    private CeDao ceDao;

    @Override
    public Ce getCe(int id)
    {
        return ceDao.findOne(id);
    }

}

Ce控制器

@RestController
@RequestMapping("/ce")
public class CeController {

    @Autowired
    GererCe gererCe;

    @RequestMapping(value = "/{id}", method = RequestMethod.GET, produces = {MediaType.APPLICATION_JSON_VALUE })

    @Transactional
    public ResponseEntity<Ce> getRegroupement(@PathVariable Integer id) {
        System.out.println("/ce/" + id);
        Ce c = gererCe.getCe(id);
        System.out.println(c);
        if (c == null)
            return new ResponseEntity<>(null, HttpStatus.NOT_FOUND);
        return new ResponseEntity<>(c, HttpStatus.OK);
    }
}

Spring XML

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:jpa="http://www.springframework.org/schema/data/jpa" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context
  http://www.springframework.org/schema/context/spring-context.xsd
  http://www.springframework.org/schema/tx
  http://www.springframework.org/schema/tx/spring-tx.xsd
  http://www.springframework.org/schema/data/jpa
  http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">

 <context:component-scan base-package="fr.rte_france.caqui.dao.impl,fr.rte_france.caqui.service.impl"/>     



    <jpa:repositories base-package="fr.rte_france.caqui.dao" repository-impl-postfix="Impl"/>

    <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalEntityManagerFactoryBean">
        <property name="persistenceUnitName" value="caqui"/>
    </bean>

    <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
        <property name="entityManagerFactory" ref="entityManagerFactory"/>
    </bean>

    <tx:annotation-driven transaction-manager="transactionManager"/>



</beans>

堆栈跟踪

Exception lors de l'envoi de l'évènementinclxteinitialisé(context initialized)àl'instancede classe d'écoute(listener)
org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.UnsatisfiedDependencyException:创建名为'gererCeImpl'的bean时出错:通过字段'ceDao'表示的不满意依赖:没有类型为[fr.rte_france.caqui.dao]的限定bean .CeDao]发现依赖[fr.rte_france.caqui.dao.CeDao]:预计至少有1个bean可以作为此依赖项的autowire候选者 . 依赖注释:{@ org.springframework.beans.factory.annotation.Autowired(required = true),@ org.springframework.beans.factory.annotation.Qualifier(value = CeDao)};嵌套异常是org.springframework.beans.factory.NoSuchBeanDefinitionException:找不到依赖[fr.rte_france.caqui.dao.CeDao]类型[fr.rte_france.caqui.dao.CeDao]类型的限定bean:预计至少有1个bean有资格作为此依赖项的autowire候选者 . 依赖注释:org.springframework.beans.factory.annotation中的{@ org.springframework.beans.factory.annotation.Autowired(required = true),@ org.springframework.beans.factory.annotation.Qualifier(value = CeDao)} .AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:569)org.springframework.beans.factory.injectMetadata.inject(InjectionMetadata.java:88)org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor) .java:349)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)at org . springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)a org.springframework.beans.factory.support.AbstractBeanFactory $ 1.getObject(AbstractBeanFactory.java:306)位于org.springframework.beans的org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) . 在org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons的org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)上的factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:022)( DefaultListableBeanFactory.java:776)org.springframework.web上的Org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:861)atg.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:541) org.springframework.web.context.ContextLoader.initWebApplicatio中的.context.ContextLoader.configureAndRefreshWebApplicationContext(ContextLoader.java:444) org.apache上的org.apringframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:107)中的nContext(ContextLoader.java:326)位于org.apache的org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4853) .catalina.core.StandardContext.startInternal(StandardContext.java:5314)org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase) .java:1408)在java.util.concurrent的java.util.concurrent.FutureTask.run(FutureTask.java:266)的org.apache.catalina.core.ContainerBase $ StartChild.call(ContainerBase.java:1398) . ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617)at java.lang.Thread.run(Thread.java:745)引起:org.springframework .beans.factory.NoSuchBeanDefinitionException:找不到依赖项[fr.rte_france.caqui.dao.CeD]类型[fr.rte_france.caqui.dao.CeDao]的限定bean ao]:预计至少有一个bean可以作为此依赖项的autowire候选者 . 依赖注释:org.springframework.beans.factory.support中的{@ org.springframework.beans.factory.annotation.Autowired(required = true),@ org.springframework.beans.factory.annotation.Qualifier(value = CeDao)} .defaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1406)org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1057)at atorg.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1019)org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor $ AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:566)... 24更多