abnormal
2021-06-22 14:10:56.860 ERROR 17884 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Field pet in com.demo.springboot.controller.HelloController required a bean of type 'com.demo.springboot.bean.Pet' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
The following candidates were found but could not be injected:
- Bean method 'pet' in 'MyConfig' not loaded because @ConditionalOnBean (names: user01; SearchStrategy: all) did not find any beans named user01
Action:
Consider revisiting the entries above or defining a bean of type 'com.demo.springboot.bean.Pet' in your configuration.
reason
Let’s analyze the printed error log
Let’s look at the hellocontroller class, in which the bean component of pet type is injected, but an error is reported that the injection is not successful
Then, we click the arrow icon on the left to go to the method of injecting this component. We find that it is the pet () method of the myconfig class, where the @ bean annotation is used to inject the pet component.
However, we use @ conditionalonbean (name = user01) annotation above the @ bean annotation, which means that a component named “user01” must exist in the container before the pet component can be injected, otherwise it will not be injected.
solve
Cancel the @ conditionalonbean (name = user01) annotation, or inject a component named “user01”.
But what is the reason for this mistake?Note that the bean component to be used by the @ conditionalonbean annotation condition should be declared above the annotation, not below.
Read More:
- [Solved] Springboot Startup Error: Consider defining a bean of type ‘XXX’ in your configuration.
- [Solved] Could not resolve placeholder ‘XXX‘ in value “${XXX}“
- SpringBoot IntegratenRedis Annotations and access error: EL1008E: Property or field ‘getListMember‘ cannot be found on object of type
- [Solved] Eslint error: /xxx/components/xxx import should occur after import of /xxx/utils/xxx
- [Solved] ibatis.builder.BuilderException: Error parsing Mapper XML: Could not resolve type alias ‘XXX‘
- [Solved] Android Develop Error: xxx does not have a NavController set on xxx
- error: field ‘XXX’ declared as a function [How to Solve]
- Tk.mapper Common mapper Error: Error creating bean with name ‘commonMapper‘ defined in file xxx
- [Solved] fastapi error: {“detail”:[{“loc”:[“body”],”msg”:”field required”,”type”:”value_error.missing”}]}
- [Solved] Error getting bean using springboot: no qualifying bean of type ‘xxx’ available
- Error:invalid new-expression of abstract class type XXX [How to Solve]
- [Solved] Error creating bean with name rController‘: Unsatisfied dependency expressed through field
- [Solved] validateRenderPassDescriptor:xxx: failed assertion XXX
- [Solved] kernel: nvme nvme0: I/O xxx QID xxx timeout, aborting
- Eslint Error:“Identifier xxx is not in camel case“
- .NETproject compilation error. Type or namespace name could not be found. Visual studio automatically introduces dependency package (shortcut key)
- IDEA reports an error. Error XXX reports an error. The class cannot be found
- [Solved] flitter Name Route Error: Could not find a generator for route RouteSettings(“XXX”, null) in the _WidgetsAppState
- The spring project is normal locally, and the bean cannot be found error is thrown when entering the docker container
- MyBatis: Mapped Statements collection does not contain value for xxx