I am working with version Spring 4.0 and learning DI in Java. I have a Shape interface and once class that implements it:
@Component
@Lazy
@Scope(value="prototype")
public class Circle implements Shape {
public Circle() {
System.out.println("Ctor Circle");
}
@Override
public double GetArea() {
// TODO Auto-generated method stub
return 2.0;
}
}
and simple class which will get the shape in injection
@Service
@Lazy
public class ShapeHolder {
@Autowired
//@Lazy
private Shape cShape;
public ShapeHolder() {
System.out.println("Ctor shapeHolder");
}
}
when the @Lazy above the field is commented all is working however when it isn't commented, I am getting exception
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'shapeHolder': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.base.Interfaces.Shape com.base.services.ShapeHolder.cShape; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
Am I doing something wrong? I want that the injection will be real Lazy.