开发者

Should I go for Spring or stick with Java EE 6? [closed]

开发者 https://www.devze.com 2023-02-04 08:48 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question w开发者_开发问答ill likely so
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question w开发者_开发问答ill likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I will be finishing the core Java course and now I have to move on to Java EE side. I am so much confused that I should simply go with Java EE 6 because I have the books which easily teach from start to end and everything is there.

Or should I start with Spring only?

Because as I have to start from scratch it is good I follow the trend which is good and more job oriented.

Or even if I do Java EE only and then if I need to move on to Spring it will be fast or vice versa.

Also where does Hibernate stand between them? I mean if I use Java EE 6, do I still need Hibernate or in Java EE 6, I don't need it.

Will I be at a disadvantage if I don't use Spring or Spring can make my building web application any way easier than the core Java EE/ JSF framework.


Though your question suggests that Spring and Java EE are two different things, in reality they are not. You can use many Java EE components like

  • servlets and JSP for Spring MVC,
  • JPA for Spring DAO.
  • JTA for Spring security

The only major thing Spring replaces in the Java EE stack is the EJB. Unless you insist on using EJBs, Spring should be the way to go. Also Spring provides inbuilt support for webservices and other things as well.

Also checkout the Groovy and Grails that use Spring as the base.

Finally I would say, functionality wise both does the same. It's code (Java EE) vs configuration (Spring), a matter of preference really.


All my comments should be taken with a grain of salt. I've been a Spring user since version 1.0; I've never used any version of EJB in production - from 1.0 to the present.

Spring has served me well: any technique that I would want to apply from Java EE is available to me in Spring. I've used the web services, LDAP, messaging, and portlet modules along with the usual suspects from persistence, remoting, and web MVC. The code is excellent. I find that emphasis on layering, coding to interfaces, dependency injection and aspect-oriented programming benefits my designs.

The truth is that you can choose either and make it work. There's little advantage or disadvantage at this point, because EJB 3 took so much from Spring that they're supposed to be similar. I can't say that from personal experience, because I haven't used EJB 3.

None of my employers or clients are clamoring for EJB 3. People in my market are using Spring or .NET to talk to web services over HTTP.

EJBs require that you use RMI or CORBA as your network protocol. I believe that HTTP based protocols - be it RPC-XML, SOAP, or REST - are winning, because simple and open usually does.

No one can foretell the future, so job prospect advice is worthless. Your local market conditions might not be the same as mine. You can hedge your bets and learn both. Whichever you choose, it's almost certain that you'll have to learn something new in the future that won't be either EJB or Spring. So pick one and be ready to change.


From my personal experience from learning Java EE/Web programming from the just standard Java, I tried to jump right into some of the frameworks without a clear understanding of how the Java EE/Web stuff worked. While not all of Java EE is relevant if you are using a framework like Spring, I think it is a good idea to have a good grasp of some of the underlying technologies. You don't have to go overboard, but understanding some of the basics is a good idea.

When something is not configured correctly in the libraries (like Spring) sometimes they assume a certain level of knowledge on their user's part. After struggling with a few basic issues, I spent some time and went back to the basics. After that I was better able to deal with the frameworks.

I would just forgo the EJB route though.


First please understand that Java EE is not a single specification, but a set of specifications. While Spring is a framework. Spring has a neat integration with many Java EE specifications including EJBs. The idea of using the specifications is to make your application portable between different implementations of this specification. Unfortunately this doesn't work very well in real life.
Now regarding Hibernate. Again: it's a framework. Java EE includes a specification called JPA. Hibernate implements JPA. You may find other implementations. So if you are using another implementation, you don't need Hibernate.

Now, you are probably want to know the bottom line. I don't really have it. If you are studying Java, the more you know, the better it will be.
If you are looking for technologies to start a new web application, I believe it's better to use Spring with a servlet container (servlet container is part of Java EE!) like Jetty or Tomcat + to use JPA (Hibernate implementation) for persistency.


Spring and Java EE 6 is in some sense similiar. They goes their way in parallel. I think it will be better if you learn Java EE 6 and then (if want/need) learn Spring.

In Java EE there is Java persistence that works very well for different database query purposes.


There is really no reason to go with Spring on a new project. There are a lot of applications out there that still use it though. You should definitely learn Java EE before Spring. Spring used to make development easier. At this point though Java EE is easier to work with and you can get rid of the Spring dependency as well.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号