springboot的常见问题错误
⼀:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
2019-03-08 16:07:14.132 ERROR 9936 --- [ main] st.context.TestContextManager : Caught exception while allowing TestExecutionListener [org.st.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@2f7c2f4f] to prepare test instance [ample.demo.DemoApplicationTests@5491f68b]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'ample.demo.DemoApplicationTests': Unsatisfied dependency expressed through field 'person'; nested exception is
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.beans.Person' 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
是因为测试的application类访问不到autowired注解的属性的对象所在的包。
application只能访问同⼀包下的⽂件,或者是同⼀包下的⼦⽂件
⼆:
java.lang.IllegalStateException: Unable to find a @SpringBootConfiguration, you need to use @ContextConfiguration or
@SpringBootTest(classes=...) with your test
是因为application和junit所在的包名不⼀样导致
三:是因为yml⽂件中存在tab键等yml⽂件有问题spring framework和spring的关系
java.lang.IllegalStateException: Failed to load property source from location 'classpath:/l'

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。