Should I learn Spring 2 or 3? - java

Spring Framework 3 seems to be right around the corner, but the GA version is 2.5.6.
If this is the first time I'm approaching the subject, should I start with the stable version, or should I start with the new version and save myself migration issues?
How different is version 3 from version 2? How near is Spring 3?

I would start with Spring 3 for various reasons:
full Java 5 support (this is main reason for adopting Spring 3 for me)
Spring MVC support is deeply change between spring 2 and 3 (notably REST support). Learning spring 2 MVC is not a far-seeing imho.
new module organization (if you start with Spring 3, you don't need to migrate packages in the future)
OSGI compabitiliy
Ivy support
You don't need to worry about bugs or incomplete documentation since you are still learning the framework concepts. In conclusion, learning Spring 3 instead Spring 2 is a far-seeing choice.
However a very good introduction to Spring 2.x is given by Spring in Action, an excellent book about the subject.

I would start with the stable version. Less bugs, more documentation, more stable and easier to find answers to issues.. Spring 3 won't be vastly different. There is a Spring 3 reference manual but it's incomplete for the changes. Also, since Spring 3 is only on a milestone release (M3), it's still subject to change.
You can read What's New in Spring 3.0 but I imagine a lot of it won't mean anything to you yet.

It's important to know required java language version:
Spring 3 needs java 1.5
Spring 2.5 needs java 1.4
Spring 2.0 and older works on java 1.3 (if you still work on legacy servers, I recently used Spring 2.0 on WAS 5.0)

Start with Spring 2 for the simple reason that if you are doing a project right now, it will be in Spring 2 and not Spring 3. I've been exploring Spring 3 for a while but working in Spring 2 and have to say that they have added a lot of nice new features in Spring 3.
This actually makes working in Spring 2 annoying because I look for the things and they aren't there. It's a little annoying - spare yourself this, I don't think you'll have any trouble learning Spring 3.

If you're learning it to start a new project that's going to be starting when Spring 3 is out learn Spring 3. If you're going to be working on an existing project that's already on Spring 2, learn that. The changes are significant enough that projects currently using 2.x are not going to jump immediately.

I wouldn't worry too much about the version; probably starting with the actual release (i.e. 2) is better than starting with one that's still in milestone releases. However, Spring 2.5, and particularly Spring MVC, can use two approaches; configuring primarily using XML, or configuring primarily using annotations. Spring is definitely moving in the direction of annotations, so if you get used to using them you should be OK.

It is possible use xml configuration and annotations in the same project.
I've made some project in 2.5 but now would like move to Spring 3.
I understand that is not easy (it is not enough only change library - need re-write code).

Related

Questions about Spring 2.5 and Java 6

I’m going to start writing my application for athletes based on Spring 2.5.6 and Java 6 (as I’ve read that Java 7 is less compatibile with this Spring version). I’ve couple of questions as I’m not familiar with such an old versions. (I need to write it for my Engineer’s Thesis – comparing app written in old version of Spring and in newest version of Sping Boot)
I know already I need web.xml, but do I need servlets to handle http requests or there is some other common way to do it? I won’t have any front sides (like jsp files) – just backend.
I mean, I want to build the most common app based on Spring 2.5 and java 6 and to do it I need these two things to do any request, right?
What about declaring beans in these versions. Do I need to do it in xml like …. or I can annotate class with for example #Component (as #Service propably does not exist in this version). Which way should I go? I would like the differences to be most visible - beetwen spring boot and old spring, so declaring beans in xml would be fine (as in SpringBoot I have annotation like #Service, #Repository etc) - but it’s hard to explain in my Engineer's Thesis why I’ve chosen for example declaring beans in xml when I could do it easily with annotations.

java spring starter question

I am looking into Spring and I want to ask the following:
I see that there is Spring2 and Spring3.
My question is, should I ignore Spring2, or If I read on Spring2 the concepts are the same in Spring3?
I ask this, because when starting to look into EJB2 I found out that it is obsolete (replaced completely by EJB3) and I wasted my time.
Thank you
You can consider them to be the same. EJB2 to EJB3 was an incredible step forward. Spring 3 is more functionality and tons of marketing.
EJB and Spring have nothing to do with one another. Versions numbers are just numbers.
Spring 3 is an incremental imporvement on Spring 2, and works in much the same way.
EJB3 was a complete redesign of EJB 2 (and, clearly, is "inspired by" Spring).
Information about Spring2 will apply to Spring3, but some portion will be replaced with changed and/or new functionality.
Knowledge about EJB2 is not obsolete, there still exist EJB2 implementations that will need developers to maintain them. Learning EJB3 seems (to me anyway) like the way to go vs learning EJB2.
For Spring3, there is a reasonable reference document available online here.

Going from Spring 3 to Spring 2 what to keep in mind?

I've been told I have to develop a Spring 2 application (no idea myself why they don't want a Spring 3 application since they use Java 5).
The problem is that all my experience is with Spring 3.
I know there's a reference manual but I find that those are a lot easier when moving forward and not backward.
So I was wondering what the major differences are between these 2.
I'm expecting to have to do a lot more configuration work in xmls.
In Spring 3 I mostly use the #RequestMapping, #ModelMapping, path binding in the jsp, automatic type conversion from String to date, hibernate-validator, ...
Any pointers would be appreciated.
Firstly, if you haven't been given a reason for using Spring 2, can't you find out what that reason is? They may not be aware of Spring 3's existence. It can't hurt to ask, especially if you tell them you're more proficient in Spring 3.
Failing that, then most of the features you've mentioned work OK in Spring 2.5.6 (including annotation-based MVC, form tags), with the notable exception of the Hibernate Validator integration. You'll have to use the other validation techniques mentioned in the ref manual instead.
Most of the Spring 3 new stuff was really under the covers, with much of the infrastructure rewritten.
I belive the REST support stuff was new in Spring 3.0. So you will not be able to bind a path variable to an method variable
//Spring 3.0
#RequestMapping("/customer/{id}/logoContent")
public void getCustomer(#PathVariable("id") final Customer customer) {...}
An additional source of the major changed between Spring 2.5 and Spring 3.0 could be the Spring Blog. This blog has a lot of posts showing the new features of Spring 3.0 (autumn of 2009 till middle of 2010). -- So this post can give you a hint what possible is not so easy in 2.5.
In my personal opinion the major different between Spring 2 and Spring 3 was the shift of configuration from Xml (Spring 2) to Annotations (Spring 3).
BTW: You should check if there is still a security/bug support for spring 2!

appfuse vs roo - what would you use

Appfuse vs. Roo, what would you use and why?
What are the sweet spots of each.
As per the answer I gave to TheServerSide thread on this issue...:
AppFuse aims to provide a single initial scaffold of your new project. This is similar to Maven archetypes or Eclipse's "new project" features in that you run them once at the start of a new project and then you maintain the scaffolded code going forward. The scaffold system has no further involvement in your project once you've run it once.
Roo, on the other hand, provides a round-trip aware active code generator for your long-term usage on a given project. As such Roo offers value both at initial creation time as well as whenever you are modifying the project going forward.
In practical terms this means as you evolve your project, Roo will automatically maintain certain files. To take a simple example, when you add (or remove) a field, Roo will update the toString, getters/setters, JSP pages etc for you automatically. It also offers commands so you can add new capabilities later. So if you need to add security six months after you created the project, you just "security setup". Or if you need to send emails, you just "http://static.springsource.org/spring-roo/reference/html/command-index.html#command-index-email-sender-setup". There are similar commands for many other capability areas well, such as Spring Web Flow, JUnit, Selenium, common JPA providers etc. You just defer the decision as long as you like, and Roo will only add those capabilities at the time you ask for them (and it will also automatically use those new capabilities in your project).
There are many other differences as well. Roo allows extension via user-developed add-ons, it offers a highly usable shell, it allows you to incrementally build a new project and add features only when required, it extensively supports the latest versions of the major Spring technologies, it comes with a SpringSource-developed (and therefore endorsed) application architecture and so on.
A read of the Roo Reference Guide's Introduction Chapter or simply completing the ten minute test project will illustrate they are very different in approach.
My notes on AppFuse and Roo:
AppFuse
Is a fully working template application/project.
Traditional DAO <-> Service <-> Controller architecture
Easy to get started with maven archetypes
Great documentation and tutorials
Not really up to date. Spring 3 final is soon to be released and AppFuse is based on 2.5 (?)
Spring Roo
Spring Roo on the other hand is a tool that speeds up development by using code generation.
Getting started with a new, fully configured project takes 1 minute
Creates rich domain objects where CRUD are weaved into the domain objects using AOP instead of traditional DAOs/services
Hard to grasp if you are new to Spring
Documentation is not that good yet
Really cool! I.e. add Spring Security to your project with just one line of code!
Telosys (a lightweight code generator) is also a good alternative. See
http://www.telosys.org/
It produces very clean code (without adherence like ApectJ)
and the templates are customizable
There's a stack of templates designed to generate Spring MVC web apps (and many others to generate code for other kinds of frameworks).
for me Appfuse but it is not up to date, but the spring roo using aspectj and there are parts of code you should not touch and I do not like that.
Spring Roo
Pros.
1.
Customizable : You add and remove diffrent framework and addon as per your requirement.
Database Reverse Enginnering : Create CRUD applications if you have database schema ready.
Strong Spring community support.
NOSQL MongoDB support
Can create required add-ons.
Cons :
Require in depth knowledge of Aspect oriented and Spring stack.
Require little more time to learn spring roo as compared appfuse.
Appfuse:
Pros:
Good one to start small and mid-size enterprise application with
struts, JSF and Spring
Complete open source code.
Enough documentation.
Twitter-bootstrap ready.
Cons:
Customize application but not like Spring roo.
For starters, roo looks more over engineered, with code generation, use of aspect oriented programming and more.
Appfuse doesn't seem to be maintained anymore seeming that the last version was released on May, 2008.
Roo it's right now a little bleeding edge, because of the use of the still-unreleased version 3 of Spring Framework, but that will change, and that version brings a lot of interesting changes to the table.
It also upsells you on more of the Spring technologies portfolio, such as STS and tcServer, and makes it dead easy to use Spring Security and Spring WebFlow.
I am going with ROO.
I am already using
Spring
Spring ORM/JDBC
Spring MVC
Spring Remoting
STS (Tool-suite)
So my preference is SpringSource products, AS I am already familiar with API style, documentation, conventions of SpringSource and even their coding practices once I extended/implemented security-framework's code.. ;-)
so, my advice is go with the tool/framework which is more natural to you..
Cheers,
AppFuse -> change to SpringFuse
I more prefer use SpringFuse
The question is some years old and in the meanwhile there are new productivity tools I want to point out:
Generjee. Generjee is a full-online tool. You define online your requirements and the (optional) data model. Then you get the generated code as a download.
The generated code is independent from generjee. The tool is useful for starting development projects from an integrated full-stack code base.
generjee will generate for you:
JPA code according to your data model
JSF code to create, read, edit, filter, sort and export data
user management, registration and login
your defined user roles and specific access permissions for this roles
I18N support
file upload support
Forge. To describe it in some words, it is "like Roo". But Forge is not as strong based on Spring and AspectJ as Roo.
AppFuse has integration with Tapestry, Wicket and other Web frameworks which Roo does not - yet
The AppFuse project was shut down in April 2016. Its founder, Matt Raible, recommends using JHipster as an alternative.

Does Spring Webflow 2.x still support gradual conversion from Struts 1.x?

I've been trying for a long time to move this large project I'm working on away from the now quite dated struts 1.x framework and on to something newer.
The main blocker has been that we aren't given enough time for a complete re-write.
I came across this article:
http://www.devx.com/webdev/Article/28041/0/page/3
Which seems to suggest that web-flow would be a good/easy way to start getting out of struts actions.
Unfortunately when I downloaded the current 2.0.8 release of web-flow I found that all of the struts classes are no longer included.
Is there a separate project for the struts integration? Or has it just been flat out dropped?
All my searches seem to turn up information about older versions.
No answers here, or on the spring forum, most likely due to lack of interest in struts 1.x (can't blame people for that).
For what it's worth, the classes aren't in the 2.x web-flow jar's nor in any other module I've been able to find for the 2.x spring framework, so basically the answer is no, out of the box, you've got to completely drop struts 1.x
We haven't investigated porting the integration classes to webflow 2.x ourselves yet, but it's an option we're considering
Just came across this. According to Keith Donald in this post it does NOT support integration with Struts 1.0 out of the box since version 2x.

Categories