Monday, 26 August 2013

Why is my @Autowired failing for web service?

Why is my @Autowired failing for web service?

I have the following, but my @Autowired doesn't work for some reason
because it remains set to null:
@Component
public class Face {
public void smile();
}
public class Parent {
@Autowired
protected Face face;
}
public abstract class AbstractParent extends Parent {
}
@Named
@Path("/parent/blueParent")
public class BlueParent extends AbstractParent {
@POST
@Consumes("application/json")
@Produces("text/plain")
public void describe() {
// crash here because face is null when I curl to /parent/blueParent
face.smile();
}
}
Anyone know what may be the problem? Is it because @Autowired doesn't work
with abstract classes?

No comments:

Post a Comment