This has apparently gotten a fair amount of attention over the last year or so, but I never encountered it until today- call me lucky. Here’s the situation, you’re using Spring MVC and you have a controller that extends another controller (A->B).
Your unit test extends AbstractTransactionalDataSourceSpringContextTests, and makes use of autowiring.
You write your test, run it, and receive something like this:
Unsatisfied dependency expressed through bean property 'aController': No unique bean of type [org.reverttoconsole.majorapplication.controller.aController] is defined: expected single matching bean but found 2: [aController.htm, bController.htm]
I tried using annotations, using @Autowire and @Resource, but in the end had to refactor my code to fit the tests… by creating an Abstract class that both controllers could extend.
Post a Comment