Spring @Autowired object is null

Viewed 2143

I'm writing a specification class in spock framework.

    @ContextConfiguration(classes = [MyServiceImplementation.class])
    class MyServiceSpecification extends Specification {

         @Autowired
         private MyService myServiceImplementation

         def "  " {
             //code
         }
    }

The class MyServiceImplementation is annotated @Service. I'm not using XML configuration. MyServiceImpl is an implementation of the interface: MyService.

Why is the autowired object myServiceImplementation null?

I tried using ComponentScan and it still didn't work.

1 Answers
Related