问题
In the previous J2EE versions, it was common practice to complement the default libraries with frameworks like Spring, Hibernate, Struts, etc.
Java EE 6 seemed to close the gap (with CDI, JPA, JSF2.0, etc.) - should I still use additional frameworks (Seam? A faces library? Spring?)
I am currently using the default Oracle stack - GlassFish v3, JSF (Mojarra) 2.0
回答1:
The common practice in J2EE 1.3 and J2EE 1.4 was indeed to supplement the J2EE stack with quite a lot of additional frameworks. Theoretically you could build an application using only J2EE, but I think not even Sun recommended doing that for any non-trivial application.
The frameworks you mentioned (Spring, Hibernate and Struts) are exactly the ones I remember that were often used.
Starting from Java EE 5, and now certainly with Java EE 6 you don't need additional frameworks anymore. Everything the core Spring container added to J2EE can now be done with the lightweight EJB3.1 and CDI component models, ORM support is provided by JPA (which is often implemented by Hibernate, but that aside) and an MVC web framework is part of the standard stack via JSF 2.
Of course individuals may still prefer the Spring and Struts programming APIs, but with Java EE 6 there is no pressing need to use them. Or put differently, it's no longer absolutely needed to complement Java EE.
That said, Seam does provide some nice (portable) extensions to Java EE and JSF was actually build to be used with extension and third party component libraries. Such component library is however not really a 'framework', but just gives you extra widgets to use on your pages. It's not the same thing as replacing JSF with say Struts or GWT.
回答2:
I'm not really sure I understand your question.
If a third-party library/framework adds some functionality that is non-trivially beneficial to your application, you should almost certainly use it (political restrictions notwithstanding). If you don't get any benefit from a framework, leave it out.
I really don't think you should think of this in terms of "complementing the default libraries" - it's simply a case of what's the most efficient and most robust way of creating an application with the functionality that you need.
So simply evaluate the technical merits of each framework (individually) against what you're currently using, and then go with the most appropriate one. The correct answer will vary depending on your individual circumstances, so it would be wrong for someone to say e.g. "Yes, you need Spring and Hibernate but ignore Struts."
来源:https://stackoverflow.com/questions/4051077/do-i-need-frameworks-to-complement-a-java-ee-6-jsf-2-web-app-which-ones