I have a maven mutli module project :
Project
-ProjectDAO
-Projectx
ProjectDAO uses spring + hibernate
From Projectx I am trying to use something like below:
public class TesMessage implements ITesMessage {
@Autowired
private IGlobal iGlobal;
...
iGlobal.getSomeMethod();
}
.. With the above code I get Null Pointer exception, Am i missing anything?
I have this in my appContext.xml
<context:component-scan base-package="com.test.nty.dal">
<context:include-filter type="annotation"
expression="org.springframework.stereotype.Repository" />
</context:component-scan>
Thanks
Believe the exception: Yes, you're missing something.
You don't show how you've annotated the IGlobal
interface. The exception suggests that it's not under Spring's control. You have to let the Spring app context handle its creation as well as your TextMessage
.
I would question this design. I don't see why every text message would need something global. Looks like a singleton bottleneck to me.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.