Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring错误:没有用于reposiotry的合格bean_Spring - Fatal编程技术网

Spring错误:没有用于reposiotry的合格bean

Spring错误:没有用于reposiotry的合格bean,spring,Spring,我不知道为什么会出现这个错误。下面是类和配置的详细信息。所有的类都在org.ew.bonder.device下,我不确定是否必须为DevicePository类添加任何注释 root.xml DevicePository.java 您必须添加到配置类中,或者在您的情况下使用XML等价物:我不熟悉此实现,但我知道在另一个Spring实现中,您需要定义一个存储库配置,该配置将扫描接口的包,以便他们知道如何为其创建代理实现。我想如果你知道怎么做,它会正确注射。 <?xml version="1.

我不知道为什么会出现这个错误。下面是类和配置的详细信息。所有的类都在org.ew.bonder.device下,我不确定是否必须为DevicePository类添加任何注释

root.xml DevicePository.java
您必须添加到配置类中,或者在您的情况下使用XML等价物:

我不熟悉此实现,但我知道在另一个Spring实现中,您需要定义一个存储库配置,该配置将扫描接口的包,以便他们知道如何为其创建代理实现。我想如果你知道怎么做,它会正确注射。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:mvc="http://www.springframework.org/schema/mvc"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans.xsd
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
       http://www.springframework.org/schema/context
                      http://www.springframework.org/schema/context/spring-context.xsd
       http://www.springframework.org/schema/context
       http://www.springframework.org/schema/context/spring-context.xsd">

    <!-- Have Spring servlet handle all static content -->
    <mvc:default-servlet-handler/>
    <mvc:annotation-driven />

    <context:component-scan base-package="org.ew.bonder.device"/>
@Service
public class DeviceServiceImpl extends BaseService implements DeviceService{
    private Logger LOG = LoggerFactory.getLogger(DeviceService.class);
    private DeviceRepository deviceRepository;

    @Autowired
    public DeviceServiceImpl(Validator validator, final DeviceRepository deviceRepository) {
        super(validator);
        this.deviceRepository = deviceRepository;
    }

    @Transactional
    public DeviceApi saveDevice(DeviceApi deviceApi) {

        return null;
    }

    @Transactional
    public DeviceApi createDevice(DeviceApi deviceApi) {
         LOG.info("Validating device request.");    
         validate(deviceApi);
         Device device = new Device(deviceApi);
         deviceRepository.save(device);
         return null;
    }

}
public interface DeviceRepository extends MongoRepository<Device, String>  {

    @Query("select d from Device d where ownerid = ?")
    DeviceApi findByOwnerid(String ownerid);

}
Jul 24, 2015 2:02:18 PM org.apache.catalina.core.StandardContext listenerStart
SEVERE: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deviceServiceImpl' defined in file [/xxxx/apache-tomcat-7.0.59/webapps/ROOT/WEB-INF/classes/org/ew/bonder/device/DeviceServiceImpl.class]: Unsatisfied dependency expressed through constructor argument with index 1 of type [org.ew.bonder.device.DeviceRepository]: : No qualifying bean of type [org.ew.bonder.device.DeviceRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.ew.bonder.device.DeviceRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:747)
    at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1114)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1017)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
    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.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:5016)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5524)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:901)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:877)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:649)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1081)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1877)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:745)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.ew.bonder.device.DeviceRepository] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1103)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:963)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:858)
    at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:811)
    at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:739)
    ... 28 more