2010-3-11 16:06:00 net.sf.ehcache.config.ConfigurationFactory parseConfiguration
警告: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/E:/kenny/%e9%a1%b9%e7%9b%ae/shops/webapp/WEB-INF/lib/ehcache-1.6.1.jar!/ehcache-failsafe.xml
2010-03-11 16:06:02,734 [main] ERROR [org.springframework.test.context.TestContextManager] - Caught exception while allowing TestExecutionListener [org.springframework.test.context.support.DependencyInjectionTestExecutionListener@1292d12] to prepare test instance [com.zzh.entity.product.BrandServiceImplTest@4e32c8]
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.zzh.entity.product.BrandServiceImplTest': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zzh.service.product.impl.BrandServiceImpl com.zzh.entity.product.BrandServiceImplTest.brandServiceImpl; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brandServiceImpl': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zzh.dao.product.BrandDao com.zzh.service.product.impl.BrandServiceImpl.brandDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.zzh.dao.product.BrandDao] is defined: Unsatisfied dependency of type [class com.zzh.dao.product.BrandDao]: expected at least 1 matching bean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireBeanProperties(AbstractAutowireCapableBeanFactory.java:329)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:110)
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:75)
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:255)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.createTest(SpringJUnit4ClassRunner.java:111)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.invokeTestMethod(SpringJUnit4ClassRunner.java:148)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:51)
at org.junit.internal.runners.JUnit4ClassRunner$1.run(JUnit4ClassRunner.java:44)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:27)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:37)
at org.junit.internal.runners.JUnit4ClassRunner.run(JUnit4ClassRunner.java:42)
at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:97)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:46)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zzh.service.product.impl.BrandServiceImpl com.zzh.entity.product.BrandServiceImplTest.brandServiceImpl; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brandServiceImpl': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zzh.dao.product.BrandDao com.zzh.service.product.impl.BrandServiceImpl.brandDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.zzh.dao.product.BrandDao] is defined: Unsatisfied dependency of type [class com.zzh.dao.product.BrandDao]: expected at least 1 matching bean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
... 19 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'brandServiceImpl': Autowiring of fields failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zzh.dao.product.BrandDao com.zzh.service.product.impl.BrandServiceImpl.brandDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.zzh.dao.product.BrandDao] is defined: Unsatisfied dependency of type [class com.zzh.dao.product.BrandDao]: expected at least 1 matching bean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:243)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:959)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:472)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:671)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:610)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
... 21 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.zzh.dao.product.BrandDao com.zzh.service.product.impl.BrandServiceImpl.brandDao; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.zzh.dao.product.BrandDao] is defined: Unsatisfied dependency of type [class com.zzh.dao.product.BrandDao]: expected at least 1 matching bean
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:435)
at org.springframework.beans.factory.annotation.InjectionMetadata.injectFields(InjectionMetadata.java:105)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessAfterInstantiation(AutowiredAnnotationBeanPostProcessor.java:240)
... 34 more
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.zzh.dao.product.BrandDao] is defined: Unsatisfied dependency of type [class com.zzh.dao.product.BrandDao]: expected at least 1 matching bean
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:613)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:412)
... 36 more
autowire异常主要由三个情况发生的
像上面的情况是BrandDao没有注入,
1。你的BrandServiceImpl必须以@Service或@Component注解才行。
2。自动写入的时候把接口写成实现类了
@Autowired
private BrandServiceImpl brandServiceImpl;
应该是
@Autowired
private BrandService brandService ;
3.在BrandDao 类上加上@Repository注解
分享到:
相关推荐
例如,我们有三个类:Person、Cat和Dog。Person类可能需要依赖Cat和Dog,传统的做法是通过setter方法或者构造器来手动注入。但在Spring中,我们可以这样定义: ```java public class Person { @Autowired private...
本篇将详细探讨"3Spring使用annotation方式autowire"这一主题,包括注解驱动的自动装配(Autowiring)以及相关的源码分析。 ### 一、注解驱动的自动装配 自动装配是Spring框架的一个核心特性,它允许框架自动管理...
默认情况下,用户请求一个 Servlet 时,容器会为当前用户创建一个会话;当用户请求一个 Jsp 页面时,容器不会为当前用户创建一个会话。 五、J2EE 事务管理 J2EE 事务提供了两种方式,一种是由编程式事务来管理,另...
这个集成项目是基于这三个框架的整合,旨在提供一个可快速开发、易于维护的后端系统基础。下面将详细阐述这三个框架的主要功能和它们集成时的关键知识点。 Struts1.3.8是Apache Struts的第一个稳定版本,它是一个...
Spring 简化了 Bean 的配置,提供了自动装配(autowire)机制,根据指定的原则(通过的 autowire 属性指定)进行 Bean 的自动装配,Spring 本身为 autowire 属性提供了五个选项:no、byName、byType、constructor、...
SSH开源框架日志心得主要涵盖了Struts2、Spring和Hibernate这三个核心组件的集成与使用,以及Spring的装配策略和单例、多例模式的应用。以下是这些知识点的详细说明: 1. **Filter、Interceptor、AOP**: 这三个...
本文将介绍如何在 Spring Boot 中使用注解将值注入参数,主要涵盖了定义注解、定义注解处理类、使 Spring Boot 支持该拦截器三个方面的内容。 一、定义注解 在 Spring Boot 中,定义注解需要使用 @interface ...
接下来,我们将详细探讨这三个概念及其在实际开发中的应用。 首先,`parent`标签用于表示继承关系。在Spring的XML配置文件中,当一个bean定义使用`parent`属性引用另一个bean定义时,它将继承父bean的所有属性,...
SSH三大框架整合指的是将Spring、Struts和Hibernate这三个在Java Web开发中广泛应用的开源框架进行集成,以构建高效、灵活的Web应用程序。SSH是Java世界里最著名的MVC(Model-View-Controller)架构模式的实现,每个...
Spring 的依赖注入有三种方式:接口注入、Setter 方法注入、构造方法注入。 在单例对象中使用多例对象,应该注意什么? 在单例对象中使用多例对象时,需要注意对象的生命周期和线程安全问题。 通过实现 ...
在默认情况下,用户请求一个 Servlet 时,容器会为当前用户创建一个会话;而当用户请求一个 JSP 页面时,容器不会为当前用户创建一个会话。 五、J2EE 事务管理 J2EE 事务提供了两种方式来管理事务,一种是由编程式...
SSH 指的是 Spring、Struts 和 Hibernate 三个开源框架的组合。在整合过程中,事务隔离级别通常由数据源(DataSource)或数据库系统决定。Spring 可以管理事务,例如通过 HibernateDaoSupport 类简化 Hibernate 与 ...
S2SH指的是Struts2、Spring和Hibernate三个框架的整合,用于构建Web应用程序。在Spring 3.2中,整合这三个框架更加顺畅。Spring可以作为它们之间的胶水,管理各层之间的依赖和事务。例如,通过`@Autowired`注解,...
1.autowire=defualt 2.autowire=“byName” 3.autowire=bytype 详细解析注入方式 例如:有如下两个类需要注入 第一个类: 1.package org.jia; 2. 3. public class Order { 4. ...
4. **整合过程**:在整合这三个框架时,首先确保各自的库文件已添加到项目中。然后,在`web.xml`中配置Spring的初始化参数和监听器,接着在`applicationContext.xml`中配置数据源、事务管理以及业务层bean。在`...
如果有多个匹配的Bean,则抛出异常。 - **`constructor`**:对于有参构造函数,根据类型进行自动装配,与`byType`相似,但是针对构造函数参数。 - **`autodetect`**:Spring会自动检测Bean的类是否有默认无参构造...
默认情况下,bean被声明为单例,意味着Spring容器只创建一个bean实例。若需每次请求创建新实例,可设置`scope`属性。 六、自动装配 Spring提供了自动装配功能,通过`autowire`属性可以实现基于名称、类型或注解的...