Kamalam
Kamalam

Reputation: 1254

Autowire annotation is not working for different package

I am using spring3,struts2 and hibernate3 together.I have a samplemanager.java file in com.top package and another test.java file in net.top package.In this test.java file i tried to use the samplemanager.java using @Autowired.But it throws null pointer exception can any one tell me a solution for this.

Upvotes: 1

Views: 1568

Answers (2)

jddsantaella
jddsantaella

Reputation: 3687

You have to configure the component scan in your application context file for both packages:

<context:component-scan base-package="com.top.*, net.top.*" /> 

Upvotes: 1

Tony
Tony

Reputation: 1276

Check if your samplemanager class is annotated and if you scan the classpath for annotated beans in your configuration file. If it is not annotated you must define the bean in the configuration file.

Upvotes: 0

Related Questions