reset password
Author Message
Vanquish39
Posts: 134
Posted 12:18 Oct 30, 2011 |

Professor by any chance do you know or have any documentation on how to start a spring/hibernate/maven/jsp project from scratch.  I'm looking online but mostly all the tutorials are Spring 2.5 and not Spring 3.0.  The only way I can learn the framework is if I build one from scratch.  The confusing part is the xml.  I need a web.xml, persistence.xml, spring.xml.... other things I presume.


Thanks

alomo
Posts: 70
Posted 13:09 Oct 30, 2011 |

Did you check CS520 FAQs ?

Vanquish39
Posts: 134
Posted 13:17 Oct 30, 2011 |

Code is almost 3 years old.  Idea looks the same though..

cysun
Posts: 2935
Posted 13:33 Oct 30, 2011 |

The simplest way to create a Spring/Hibernate project is to use an archetype. There are tons of them to select from when you create a Maven project in Eclipse. The problem with those archetypes is that they either include libraries that I don't use or do things in ways that I don't like. One day I'll create some  archetypes myself, but until that day you can either use some existing archetype (type "spring" in Filter in the Select an Archetype windows during Maven project creation in Eclipse), or do it manually yourself. Here's the manual process:

1. In Eclipse, create an Maven webapp as described here.

2. Add all the Spring dependencies. You can just copy all the spring-* dependencies from CSNS2's pom.xml.

3. Add <servlet> and <servlet-mapping> for the Spring DispatcherServlet to web.xml. Use the web.xml in CSNS2 as an example. You just need one spring configuration file (for now) specified as an <init-param> of <servlet>.

4. Use spring.xml in CSNS2 as an example to create the Spring configuration file. You need the following:

  • <mvc:annotation-driven>
  • <context:component-scan> so Spring can find your controllers and other beans.
  • A view resolver. For simplicity just use an InternalResourceViewResolver so you can use plain JSP for views.

5. Create a controller and a JSP and try it. If it works, comes back here and I'll tell you how to add Hibernate.

Vanquish39
Posts: 134
Posted 22:21 Nov 09, 2011 |

Ok Professor I found some extra time on my hands and I setup a project from scratch using Spring Tool Suite.  I didn't know that STS was literally just like eclipse.  All the spring templates and roo projects had maven integration.  So anyways, I made the web.xml, spring.xml, the controller, the view and they are working properly.  Please if you would be so kind and help me integrate hibernate also, I would be grateful. 

If it's not too much to ask can you please provide both jpa specific and hibernate specific.  I.E EntityManager and SessionFactory.


Also, I want to include the jquery-min script into my project so i can use it in the jsp.  Do I have to put it somewhere in web.xml or just create a folder and put the script in it? 


Thank you.

Last edited by Vanquish39 at 22:23 Nov 09, 2011.
cysun
Posts: 2935
Posted 09:54 Nov 10, 2011 |

I'll post a guide later today or early tomorrow.

Vanquish39
Posts: 134
Posted 11:31 Nov 10, 2011 |

Thanks Professor, I really appreciate it.  I feel like the only way I will learn this is if I start from scratch.    Also, besides jsp/jquery combo, let's say I wanted to use another front end view, maybe Flex.  How would you incorporate this?  Would you just change the viewresolver and do sometimes like tiles.  Also Flex is more rich compared to just jsp and jquery right?

cysun
Posts: 2935
Posted 13:51 Nov 11, 2011 |
cysun wrote:

I'll post a guide later today or early tomorrow.

Please check out Spring and Hibernate from Scratch.

Vanquish39
Posts: 134
Posted 14:00 Nov 11, 2011 |

Thank you very much, you have no idea how much help this is to many of us.  Thank you once again.

cysun
Posts: 2935
Posted 14:17 Nov 11, 2011 |

As for jQuery and other JavaScript libraries, you can either download  a copy and include it in your project, or link to a copy hosted on some content distribution network (CDN) like Google Libraries API. The benefit of having a local copy is that you do not need internet connection during development, but linking to a CDN hosted copy is recommended for production use.

And for FLEX, as far as I know there's no Spring view resolver for that. The main reason is that things like Flex and Silverlight are platforms by themselves, not just a view technology under MVC. Usually these technologies operate under the event handling model (and in that sense they are more like ASP.NET and JSF rather than MVC frameworks like Spring and RoR), and they typically interact with the server side using web services or some type of remote procedure call.

Vanquish39
Posts: 134
Posted 14:26 Nov 11, 2011 |

yea the GWT is the same, it's based on remote procedure calls.  Do you think future wise there will be a view implemented for these also?

Vanquish39
Posts: 134
Posted 14:33 Nov 11, 2011 |

Professor I can't view the videos for the homework5.  The email video and the others.  Does it just take really long to load? 

cysun
Posts: 2935
Posted 14:44 Nov 11, 2011 |
Vanquish39 wrote:

yea the GWT is the same, it's based on remote procedure calls.  Do you think future wise there will be a view implemented for these also?

Spring can be used with many things. I wouldn't be surprised that you can already use Spring together with GWT, but my understanding is that in those settings Spring is used in more of a "supporting role" to provide capabilities like dependency injection and AOP, but not as an MVC framework.

Last edited by cysun at 14:50 Nov 11, 2011.
cysun
Posts: 2935
Posted 14:46 Nov 11, 2011 |
Vanquish39 wrote:

Professor I can't view the videos for the homework5.  The email video and the others.  Does it just take really long to load? 

Those videos are simply wmv files. Try downloading them then view locally.