Announcement Announcement Module
No announcement yet.
How to autowire a bean loaded by Hibernate? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to autowire a bean loaded by Hibernate?

    Hi, I'm using Spring 3.1.0.RELEASE. One of my Hibernate classes (EventFeed) references a class (AbstractEventParser ), in which I'd like to get access to a service, loaded by Spring. However, my autowiring is failing (the service is always null). I'm trying ...

    public abstract class AbstractEventParser {
    	protected NetUtilsService netUtilsService;
    And my service class has

    public final class NetUtilsServiceImpl implements NetUtilsService {
    but the netUtilsService member field is always null in the AbstractEventParser class above. What do I have to do to successfully autowire the field in the "AbstractEventParser" class? I have verified that my applicationContext.xml scans the class ...

    	<mvc:annotation-driven />
    	<context:component-scan base-package="com.myco.myproject" />
    Thanks, - Dave

  • #2
    I suggest a read of the reference guide. Basically, as you already noticed, your @Configurable is pretty much useless, there is nothing which knows what to do with that annotation. You need to add a context:spring-configured which enables the @Configurable, depending on your environment you need additional configuration, I suggest a read of the reference guide.


    • #3
      I was trying to follow the instructions here --, but before I go crazy, is there another way I should be doing this that is simpler to configure than the aspect-oriented angle?


      • #4
        No... As you need it to be woven in the class. You want injection when an object is constructed and outside of spring and as such you need additional capabilities.