Only one annotated constructor per-class can be marked as required, but multiple non-required constructors can be annotated.
If I have one autowired constructor, all is fine. If I have two or more autowired, but required=false annotated constructors, all is fine. But if I mix them in a way, such that there is one or more required=false constructor autowiring annotations and exactly one with the required=true, it throws an exception.
org.springframework.beans.factory.BeanCreationException: Invalid autowire-marked constructor: public annotationconfig.SomeBean(annotationconfig.AnotherBean). Found another constructor with 'required' Autowired annotation: public annotationconfig.SomeBean(annotationconfig.AnotherBean,annotationconfig.AnotherBean)
Is this expected behavior? Am I missing something about how Spring dependency injection works? If this is normal, why is this a problem for Spring, why can't it handle a setup like this?
asked Jul 13 '14 at 13:55
52311 gold badge77 silver badges1414 bronze badges
- Do Hindus have a rule book
- How is oxygen transported to the ISS
- Why is slavery still wrong
- Will entrepreneurship ever become obsolete
- How do I restore my curiosity
- Why doesnt Emirates fly to Kathmandu 1
- How has Noam Chomsky influenced Steven Pinker
- Why dont we have plastic road
- Is there any all purpose programming language
- What is the scientific name for bedwetting
- Is busking allowed in San Francisco
- What is Mick Hucknall famous for
- What is the best free email account
- What are your thoughts about Unshackled
- What can you see in Polis Cyprus