Why won't this dao class autowire?

Spring can only handle Spring Beans, and can only inject in Spring Beans. If you have a class that is instantiated in a Pojo way by new (or loaded form the database by ...) it does not become a Spring Bean. But you can make even this Pojos become Spring Beans.

You need 3 things: add @Configurable to the Entity turn on Spring Configurable support: enable AspectJ (AspectJ not Spring AOP) - compiletime or loadtime weaving. -- If you use compiletime weaving you need to use an AspectJ Compiler @See: Spring Reference: Chapter 7.8.1 Using AspectJ to dependency inject domain objects with Spring Using Spring’s @Configurable in three easy steps Spring, Aspects, @Configurable and Compile Time Weaving using maven.

He's using component-scan to scan for classes annotated with the @Component annotation. When configured properly, this should be fine. – M Platvoet Jun 21 at 7:41 If you need elaborate injection, a class annotated with @Configuration can provide extra beans; just annotate the relevant factory methods with @Bean.

Since that configuration class is also a component itself, you can inject its own configuration into it; this can be a really good solution to tricky injection problems. – Donal Fellows Jun 21 at 7:53 @Donal Fellows: Is there any way to make – Ralph Jun 21 at 8:35 @M Platvoet: Thats why I started with: "Let my guess: AuthenticatedUser is a Domain Entity? " and then explained why it does not work per default.

– Ralph Jun 21 at 8:36 Don't know. I handle my (relatively trivial) persistence problems through JDO instead, because at the time I could figure that out in sufficient detail. – Donal Fellows Jun 21 at 9:02.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions