I've been struggling with this for awhile now and especially since working on my new book. For the persistence chapter I am putting together a couple of examples, one using Ibatis and Spring DAO's within a simple web application, another using Ibatis again with a custom DAO layer, and a third more robust example using JPA. I was considering using Spring also in the second example but have run into trouble trying to build a generic service layer that is accessible from other applications within the JVM. This is especially important in a portal environment where every portlet is a separate application.
This seems to be a major issue with using Spring, is that I can't create a truly separate layer that's implementation approach is hidden from the layer above. Even if that were not the case is would be trouble trying to share the same Spring context across multiple applications. I would end up with multiple copies of my objects, one for each application. I have found some work arounds for web apps within the same enterprise application, but I'm not sure I like the solution, and it's not truly global.
The truth is I want my business logic, or presentation layer to not even know I'm using Spring in the lower layers. I would end up wrapping things in a singleton anyway. For complex applications where I wanted to use dependency injection and other features this would probably be ok, but I might just design my app to be Spring free knowing I'll end up there anyway.
Don't get me wrong, I like the concept of Spring and am a big fan. I'm just looking for cleaner solutions for my architectures. I'd be interested in any thoughts or work around that people have found. I know that many portal customers are looking at using Spring, but am not sure that many have through it through to this level?