- This topic has 3 replies, 2 voices, and was last updated 13 years, 11 months ago by
jkennedy.
-
AuthorPosts
-
Greg SoulsbyMemberWe are try to keep the proprietory classes apart from the “generated” directory, in the hope of simplifying re-scafolding.
Can get access to our proprietory classes from the generated classes by updating /resources/…generated-service-context.xml to scan our directory. Then @Autowire picks up the prop classes from within the generated class. Cool.
I cant get it to work the other way around – I want to @Autowire generated classes into my proprietory classes. But they are null to start with and I cant find how to initialise them.
jkennedyMemberYou should see both a service-context.xml and a generated-service-context.xml file. The generated one can be modified, but our design goal was to actually put the service-context.xml file there for you to modify leaving the generated one for us to modify, etc. You will notice if you look through the context files, and the web.xml file, that we load specific context files and then those context files import other context files. We left the “non generated” files for developers to modify by hand.
Regarding the issue of not being able to Autowire our beans into your beans, there must be some issue with the order of the component scanning I think. One thing to try would be to add the autowire of your classes to the service-context.xml file. You could also try creating your own context file and then adding that context file to the list of context files that are being loaded in the web.xml file where it configures the Dispatch Servlet:
org.springframework.web.servlet.DispatcherServletIf you can’t get it to work, please send me a copy of your project (or similar) to [email protected].
I would need to know which of our objects (Services, DAOs) etc you are trying to Autowire and see where you are trying to add your component scan etc.
Thanks,
Jack
Greg SoulsbyMemberJack,
I see, separation as you have done is good.
Re:
One thing to try would be to add the autowire of your classes to the service-context.xml file.
Can you tell me give me a hint as to what that would look like? And dont worry, it doesnt have to be subtle.
Thanks
jkennedyMemberP0rridge,
Sorry, I should have been more clear.I was proposing that you try adding a line that component scans your package in the service-context.xml
<context:component-scan base-package=”your.package.here” scoped-proxy=”interfaces” />
Thanks,
Jack -
AuthorPosts