It's a short question without a trivial answer. The Java EE Framework does not evolve so fast, but it includes more and more features, some of them taken directly from other open source projects like spring and hibernate. Can you list some of the reasons why you still use spring instead of just relying on the standard Java EE features, and maybe comment each reason with a few words?
Thanks in advance!
You can go through sites below to know more :
spring forum
spring-3-0-vs-java-ee-6-0
Spring vs Java EE
Why Java EE Lost and Spring Won
Related
I would implement a Spring aspect in a j2ee application, can someone post some tutorials?
I've just used Spring in web application but I've not idea how to invoke a cross cutting concern in CDI container.
Thanks in advance
Is there a special need for combining Spring and CDI? If not, I'd suggest to stick to standard Java EE as long as you can solve your problem with it and only if not, look for external components (and even then, you should first check the "sort-of-standard" CDI extensionf from the Apache Deltaspike project.
Cross-cutting concerns can be solved via pure CDI - check our for example the Java EE 7 tutorial about the topic.
Small note: Don't use J2EE anymore if not maintaining an ancient application.
This question already has answers here:
When is it necessary or convenient to use Spring or EJB3 or all of them together?
(2 answers)
Closed 6 years ago.
I am currently preparing my final project study. I have to develop a distributed application for the management of human resources, but on my benchmark for technologies to use I found it confusing to decide between Spring or the EJB 3.1.
I do not know which will be the best suitable and easiest to use. I am a beginner for both technologies and therefore I hope so someone can help me.
You do not choose between EJB and Spring, you actually choose between Java EE and Spring because EJB is only a part of Java EE which includes also other components like JMS, Servlets, JSP, JSF, CDI, etc. In its early days (J2EE 1.4) programming model of enterprise edition of Java had a lot of flaws and deficiencies, but the most important ones were that it was tedious and verbose with a lot of boiler-plate code and tons of xml configurations. Spring was introduced as an alternative framework favoring convention-over-configuration principle. In other words, in Spring there were some sensible defaults that could be reconfigured if you need it. Java EE 5 introduced significant changes adopting the same convention-over-configuration principle from Spring, drastically reducing code amount and complexity required to get things going, so in this area Spring does not hold any sensible advantage any more.
It is also important to bear in mind that Java EE is just a specification. To build a real world app you need an implementation and there are plenty of them today - Glassfish, JBoss, TomcatEE, etc. all provide different implementations of Java EE specification introducing additional complexity - I mean, now you have to choose which Java EE implementation to choose. You can contrast that with Spring which comes from a single source.
Both frameworks gives you pretty much similar functionality. All support transactions, ORM, provide tools for building business logic, support CDI, AOP. In both Spring and Java EE you can only use the parts that you need, in other words you don't have to use the whole framework. You can even use them together - they can interoperate. Thanks to introduction of embeddable containers you now can even use Java EE features you need in areas like desktop applications which traditionally were the realm of Spring.
But one area where Java EE still lacks behind Spring is comfortable testability. It is not easy to write unit tests for EJB - for this you have to use a special third-party framework (Arquillian) and write some boilerplate code inside your tests (e.g. for building the test deployment package and deploying it onto the container, etc.). In fact, Java EE lacks any support for testing EJBs out of the box. In contrast, Spring is built with testability and TDD in mind. Testing Spring beans is easy since Spring includes bundled support for both testing (unit testing, integration testing) of all parts of the application as well as mocking.
I'm planning a project which will use Primefaces to generate its UI.
I understand that PrimeFaces as JSF library is somewhat more at home with Java EE than Spring, although there seems to be a lot of examples of using it together with Spring.
Are there any notable disadvantages of using Spring instead of Java EE for the DAO and service layer in a PrimeFaces project?
It complicates the things, Java EE is complex enough for application developers(you need time to open dark parts and see the lights or i hope it:)) so my opinion if you don't have a requirement about it, don't use Spring and JSF together to better understand your bean lifecycle. You can find good dicussion in this source. I prefer to use HTML+Bootstrap and Spring MVC or use Seam Framework for JSF or no framework just use pure Java EE support with primafaces(JSF) can be good.
I am very very new to Spring and I don't even know Java EE. Can I proceed with Spring? If not , then how and what things do I have to gain before moving to Spring?
Please also guide me spring flavour and the best books for the specified flavours.
Please also give brief about each flavor so that I can gain knowledge about what is used for what.
You don't need to learn Java EE for learning Spring. Spring is not Java EE and Java EE is not spring. You can develop Java EE application using spring and without spring.
From the wikipedia : The Spring Framework is an open source application framework and inversion of control container for the Java platform.
Before moving to spring, you should be acquinted with design patterns. Effective Java and Head First Design Pattern is a good book to start. You can also find multiple source online.
Once you through about design pattern. You can find the Spring very much easy and its uses.
Start with Spring core. Then move to the other sub-projects of spring.
Documentation in Spring Source is best place to start..
You have to first learn Java EE especially JSP and Servlets. Get some detailed information on MVC pattern. You also require some hands-on knowledge on Web servers. Then you can move on to learn Spring.
This is a very subjective question; what teaching aides work best depend on the individual. As far as videos go, I would start with youtube with the springsource channel for Spring related information, and even some Java EE 101 type stuff. Also have a look at slideshare.net for presentations on various Java EE and Spring topics. good luck!
I am thinking about a platform for study application (it is team work). I mean standard Java EE 5 (or maybe try raw Java EE 6) and Spring. What is your choose? (I don't mean Spring MVC but Spring Beans and EJB 3.0)
Also I would like to know what app server you use? (now I use GlassFish v2)
I would recommend Spring without EJBs.
My favorite choice of Java EE app server is WebLogic, but I don't know if Oracle is as generous as BEA was about making it available to developers.
I'd recommend using Tomcat as your app server. If you need JMS, add ActiveMQ.
As duffymo says, look at Spring without EJBs. Spring is very powerful, regardless of how much/little you use. I don't know of anyone using EJBs now. Having said that, EJBs have changed dramatically over the years, and now resemble ORMs such as Hibernate (which is worth checking out in itself).
For app servers, check out JBoss. It's free/open-source, and you can choose the web component between Tomcat and Jetty. It's JMX backbone allows you to easily monitor its state and to integrate your own JMX beans into that backbone (if you're using Spring, you can JMX-enable any bean with a simple configuration).
If you want Java EE 6 then the choice appears to be either Glassfish 3 or the beta of JBoss 6. As some of the others have said, I also prefer Spring to Java EE's EJBs.
I don't see much point in looking at Java EE 5, unless you think you will be working with it in the future (possible as some companies are conservative in using newer versions of technology).