I have 2 projects in eclipse. One contains the back end stu开发者_Python百科ff the other one facades and front end. I have service beans in the back end project which should be injected into the facades. What i did was adding a the BE project to the referenced projects of the FE project. I also created a spring configuration file in the BE project which i import from my FE project's spring configuration file like this:
<import resource="classpath:backendContext.xml" />
All i have in that file is this:
<context:annotation-config />
<context:component-scan base-package="com.mycompany.myproject" />
But the BE services which should be injected into the facades are not recognized. If i add the services into the backendContext.xml using <bean id="blah" class="blah.blah" />
everything works but i'd like to continue using the annotation based config.
I tried compiling my BE project into a jar and adding it to my FE project but the annotated beans were also not recognized when inside a jar.
I found this worked for me...
Solution in Eclipse Helios:
Open Properties > Deployment Assembly of your FE project. Click "Add..." and select your BE project.
Solution in Eclipse Galileo:
Open Properties > J2EE Module Dependencies of your FE project. Select your BE project.
Once you have made this change, restart your server and the FE project should now have the BE resources on its classpath so that Spring can find the configuration files, etc.
I hope this helps!
精彩评论