我是把base-package的路径写的不对,没有写被注入的dao类型的路径
"D:\Program Files (x86)\jdk1.8.0_251\bin\java.exe" -ea -Didea.test.cyclic.buffer.size=1048576 "-javaagent:D:\Program Files\IntelliJ IDEA 2020.2.1\lib\idea_rt.jar=62932:D:\Program Files\IntelliJ IDEA 2020.2.1\bin" -Dfile.encoding=UTF-8 -classpath "D:\Program Files\IntelliJ IDEA 2020.2.1\lib\idea_rt.jar;D:\Program Files\IntelliJ IDEA 2020.2.1\plugins\junit\lib\junit5-rt.jar;D:\Program Files\IntelliJ IDEA 2020.2.1\plugins\junit\lib\junit-rt.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\charsets.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\deploy.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\access-bridge-64.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\cldrdata.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\dnsns.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\jaccess.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\jfxrt.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\localedata.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\nashorn.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\sunec.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\sunjce_provider.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\sunmscapi.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\sunpkcs11.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\ext\zipfs.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\javaws.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\jce.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\jfr.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\jfxswt.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\jsse.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\management-agent.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\plugin.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\resources.jar;D:\Program Files (x86)\jdk1.8.0_251\jre\lib\rt.jar;E:\在做项目\SGMS\out\production\SGMS;E:\java\apache-tomcat-9.0.35\lib\jsp-api.jar;E:\java\apache-tomcat-9.0.35\lib\servlet-api.jar;E:\在做项目\SGMS\web\WEB-INF\lib\druid-1.1.9.jar;E:\在做项目\SGMS\web\WEB-INF\lib\sqljdbc42.jar;E:\在做项目\SGMS\web\WEB-INF\lib\hamcrest-core-1.3.jar;E:\在做项目\SGMS\web\WEB-INF\lib\junit-4.12.jar;E:\在做项目\SGMS\web\WEB-INF\lib\commons-dbutils-1.3.jar;E:\在做项目\SGMS\web\WEB-INF\lib\commons-logging-1.1.1.jar;E:\在做项目\SGMS\web\WEB-INF\lib\spring-beans-5.2.6.RELEASE.jar;E:\在做项目\SGMS\web\WEB-INF\lib\spring-context-5.2.6.RELEASE.jar;E:\在做项目\SGMS\web\WEB-INF\lib\spring-core-5.2.6.RELEASE.jar;E:\在做项目\SGMS\web\WEB-INF\lib\spring-expression-5.2.6.RELEASE.jar;E:\在做项目\SGMS\web\WEB-INF\lib\spring-aop-5.2.6.RELEASE.jar" com.intellij.rt.junit.JUnitStarter -ideVersion5 -junit4 Test.UserTestTest,test
九月 14, 2020 8:25:40 下午 org.springframework.context.support.AbstractApplicationContext refresh
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookService': Unsatisfied dependency expressed through field 'bookDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'Dao.BookDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bookService': Unsatisfied dependency expressed through field 'bookDao'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'Dao.BookDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:643)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:130)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:399)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1422)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:594)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:895)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:878)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:144)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:85)
at Test.UserTestTest.test(UserTestTest.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'Dao.BookDao' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1716)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1272)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1226)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:640)
... 37 more
Process finished with exit code -1