Do you like Blondes, Brunettes, or RedHeads, and why? ;)
Well the question is very open ended and I doubt you will get a full answer. But ServiceLocator is a pattern, Spring is a framework. You can do a Google search to find out the difference between that. Also Spring framework uses lots of design patterns, not just one.
well, This is one of the question has been asked in recent interview. I have very clear idea about the frame work and design patterns. It is open screat that spring has collection design patterns and service locator is one of the design pattern which has been included in spring. As per my understand (differences), Spring services are injected into your business classes rather than the business classes looking up a service.
I don't want full answer, Just to get the knowledge. I will not post this message if I get the answer in google, If you find anything in google search, give me link.
I suppose that you mean Spring IoC and Service Locator.
Spring IoC is better in terms of dependency management, the dependent doesn't look up or create dependencies, the control is inverted, the dependent just defines interfaces and the container injects dependencies to the dependent (dependency injection that is).
SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 1.3, SCJP 5.0, SCEA 5, SCBCD 5; OCUP - Fundamental, Intermediate and Advanced; IBM Certified Solution Designer - OOAD, vUML 2; SpringSource Certified Spring Professional
Yeah, I guess a good simple explanation on the difference is that Inversion Of Control is pretty much the opposite of ServiceLocator. Instead of looking up its dependencies. the dependencies are injected into the class instead. But there is so much more with Proxies and AOP to add services like Transactions and stuff. That is why it becomes a comparison of Apples to Oranges and would require a very lengthy post to list all the differences.