views:

145

answers:

4

I'm a PHP programmer and I want to try creating a webapp using the Spring framework. The problem is I'm clueless and I don't know where to start.

What tutorials/books/websites do you guys suggest that I should learn from? What's IoC? Do I use it alongside MVC? What components of the Spring framework should I use? How do I know what to use? Are there webapps created with Spring that I could study from?

Thank you so much in advance!

P.S. I've used Struts (1) about a year ago.

A: 

I'm also a php programmer [mainly] and one book I found useful when I was trying to learn Spring was Spring: A Developer's Notebook. Yes you can/probably will use IoC with MVC, they take care of different issues.

sjobe
+1  A: 

IOC (Inversion of Control) is a design pattern/principle for decoupling of components. For instance, you may have a DAO class that is utilized by two service classes. But lets say for example's sake the DataSource is different for each service class. In that case you can inject the DAO class for the two service classes with two different data source property.

ServiceClassA -> uses MyDAO with DataSource = A ServiceClassA -> uses MyDAO with DataSource = B

This link has a good example on IOC http://www.vaannila.com/spring/spring-ioc-1.html.

There are many components in the Spring framework. You can use MVC, IOC, AOP, JDBC, Transaction Management, Scheduler, etc. The best part is all of these are independent. For example you can use Struts as MVC with Spring IOC and pure JDBC or Spring JDBC or Hibernate. So what you should use really matters on what your project requires or what your organization follows.

I personally like the Spring Recipes book by Gary Mak for Spring intro.

CoolBeans
What are sevrices and where can I read more of them?
I was using Service as an example of core business class in a DAO design patter. For more info on the design patter .. check here. http://java.sun.com/blueprints/corej2eepatterns/Patterns/DataAccessObject.html
CoolBeans
+3  A: 

I'm a PHP programmer and I want to try creating a webapp using the Spring framework. The problem is I'm clueless and I don't know where to start.

Start with learning Java and object-oriented programming.

What tutorials/books/websites do you guys suggest that I should learn from?

Start with Sun's Java tutorial. Work all the way through it.

What's IoC?

Inversion of control. Read more here.

Do I use it alongside MVC?

That's one choice.

What components of the Spring framework should I use?

Start with controllers and SimpleJDBCTemplate.

How do I know what to use? Are there webapps created with Spring that I could study from?

Start with Spring MVC step by step.

Thank you so much in advance!

P.S. I've used Struts (1) about a year ago.

Irrelevant.

If you've never written a web app with Java or Spring, I'd recommend not beginning there.

Start with JSPs written with JSTL, servlets, and JDBC. No Spring, no Struts, no MVC framework. You will appreciate the frameworks more if you write a web app or two without them. You can't use Spring well without knowing those well.

duffymo
+1  A: 

Even after working with Spring for quite some time, I still refer to http://www.springbyexample.org/ from time to time. There are many great examples, and the documentation is a great resource for working with the preferred Spring practices from JDBC/DAO, to Security, to Spring MVC, etc.

When I was first starting out working with Spring, I simply picked apart the pet clinic example, which I'm pretty sure ships with Spring or maybe Spring MVC. What's nice is the Spring source code for the all of the projects as well as examples is available in SVN.

Droo