Using Spring (3.0.5) in Eclipse (3.6 Helios) - java

I just got a book from Apress (Spring Recipes), and I started to learn the Spring framework and now I have a problem. I followed the steps in the book to add the Spring .jar-s to the build path. Everything seems to work fine, but the code I have just doesn't work.
My question is that: do you know about a good tutorial for integrating Spring with Eclipse? I googled for a while and I only found old tutorials (from 2007-2009) which just doesn't work with Eclipse 3.6.

use STS - Spring Tool Suite. It is built-upon Eclipse IDE. http://www.springsource.com/developer/sts

STS helps hugely (you can get it from the Eclipse Marketplace for free). The features of it I particularly like? Here's a few:
As a user of XML-based configuration I love having the bean graph visualized – it's great for reports – but the content assist when filling out bean properties is invaluable, both for names and for values (i.e., it makes writing that much XML not suck too much). I imagine that if you're heavily using autowiring or Java configuration it's less useful.
Refactoring support is also good (these days; it used to have bad bugs so you want to be patched up to date) and I've found that the pointcut search to be the only way to write a complex aspect without lots of round-trip testing.
But not all of STS is perfect. In particular, some of the content assist modes don't (seem to) help (me) that much, and it really only works well if you have your properties defined using public setters. Still, it helps a lot…

Apart from using STS as suggested, you can use spring and eclipse without any integration. There isn't that much an IDE integration can offer anyway (apart from autocompletion in the xml, and linking the xml to classes (inclding aop))

Related

Design a Plugin based java application

I'm trying to make a plugin-based application which means, besides the basic framework, other functionalities should be added with a plugin style.
The majar problem of such system, i think, is how to load new plugins at the runtime. I don't want to recomplie the whole project when a new plugin installed. Just like Eclipse, after new installation of plugin, the user only need to restart it.
So my first idea about that is using java reflection to load the class at the runtime. there might be some plugin configuration files, the system reads them and load the plugin classes with reflection. Maybe i can use the spring framework as well, because its Inversion of Control is just match my request.
Another idea i'm investigating is using the ejb container. when the plugins are ejbs, i can just pack them into jar and deploy them in an ejb container, then i can use jndi to access them. but it only works when the plugin are ejbs.
anyway, i'm a rookie in system design. so i post this topic and want to hear of your opinions.
btw. is there any good book about system design you want to recommand?
thanks alot in advance!
You may first look at OSGI and his implementation (Equinox for Eclipse and Apache Felix) but it would be easier if you give us more information of what you are trying to do.
Plug-in to solve what problem?
Designers of frameworks usually have deep domain knowledge that informs their design choices. Frameworks come about after two or three attempts to solve some problem; the earlier implementations give clues about how to abstract what's important into a framework.
Eclipse solves the problem of an expandable IDE (poorly, in my opinion). EJBs are transactional, distributed components that run in a container.
You've given no indication of what kind of problem you want to solve. Until you do, your ideas won't get very far.

What are the prerequisite for Spring Roo

I have got my hands dirty in Spring Roo, I have managed to do the persistence set up for Oracle Database. Although I have gone through the Roo documentation
but it not enough for me to understand the working of this framework.
I'm not aware of Spring-MVC ,Spring-Web Flow and AspectJ rather I have knowledge of frameworks such Struts, Tapestry and GWT. Could this be a hindrances in learning Spring Roo.
Please advice as I'm running out of patience of hacking the generated code by Spring Roo. Is it good idea for me to jump in a Spring Roo project?
The Spring Roo is more than a code generator. If you make changes in your Entities, it will change the codes automatically. More like a stateful code generator. First you need to find out the commands available in Spring Roo to configure a project.
You can configure which database you want to use, which orm you want to use, whether you want to use unit-tests or which view technology you want to use. Give the commands and Roo takes care of it. You don't need to worry about which libraries to download, how to make pom file for Maven.
The configurations you got using Spring Roo is quite a standard one. I used it in the previous projects. The code generated is not optimal, for example , you can use generic daos instead of Roo generated DAO if you consider the generated codes are verbose.
Another example says, in Flex, you can use Roo to generate configurations for the communication between Flex client and J2EE server. For my case, I use parsley and observer patterns for flex client instead of the codes generated by Spring Roo. But by looking at the codes what the Roo-Flex team wrote taught me quite a lot of things too. The same things goes for GWT and Spring MVC.
So what am I saying is that as the programmers, we need not only to code we also need to read what the other wrote too . I strongly believe that it is a good way to learn and share best practices. You might get some boilerpate codes, but if you know how to apply design patterns or can enhance on them, those codes will become the gems.
Learning curve ? Not at all. The commands are as simple as DOS commands.
Spring ROO is just a command line interface for generating a lot of the boiler plate code you usually need to write to get things done in java projects.
If you want to add GWT into your project, just type "gwt setup" after you've created your models and you have full-on GWT support in your project.
The default view being generated in Roo uses Apache tiles, similar to Struts, Tapestry and JSF.
If you want to use web flow, just type in "web flow" and it'll be integrated for you, for struts support, you'll need a plugin, I've seen a couple of them floating around the web, haven't tested any of them; same goes for tapestry, you can either use a tapestry plugin or do the integration by hand.
AspectJ in the context of Roo generated scaffold is used to hide all the boilerplate code that makes code look like spaghetti, you can move code out of the aspectJ generated files into your own java files and modify them if you need to.
As for the hacking, it takes a lot of patience and time to fully understand where you should change stuff and where you shouldn't, all I can say is, happy hacking :-)
springroo is based on many technologies, but all what springroo does is to help you to generate scaffolding code using lots of addons you can install
at least it's my view of this framework after three days of learning it

Getting started with Spring 3 Web MVC - Setting everything up

I'm trying to get started with JAVA/Eclipse/Spring MVC but can't seem to find a "dummies" or "step-by-step" guide for setting everything up and creating the simplest proof-of-concept application.
I found http://static.springsource.org/docs/...-step-by-step/ but there seem to be differences between Spring 2.5 and Spring 3 so i'm looking for something for Spring 3.
Also, the tutorial for Spring 2.5 focuses on building the application usign Ant - This i will certainly be doing for releasing but when working within Eclipse i want to have set up the project so that i can use breakpoints/debugging and this is not covered at all.
I've downloaded Eclipse, Tomcat and the Spring 3 Framework but that's about it and within the downloaded Spring Framework documentation it states:
2.3 New getting started tutorial
There is now a new getting started tutorial
for developing a basic Spring 3.0 MVC
web application. This tutorial is a
separate document that can be found at
the Spring Documentation page
However, i can't seem to find such a tutorial on the linked page. My main problem at the moment, as seems to be the case for many people trying to get started with Spring, is that i can't seem to get everything set up.
I've got a copy of Expert Spring MVC and Web Flow and i've also found this tutorial but i don't know if the setups they describe are still relevant and whether they will allow debugging.
Can anyone please give some direction?
Thanks
Get the mvc-basic or the petcare sample apps from the Spring Samples SVN repository. These samples have been updated to Spring 3.0 and are directly importable & runnable with SpringSource Tool Suite.
I am also started to learn Spring 3.0 and i am not getting any help means any tutorials. but i find this site http://viralpatel.net/blogs/2010/06/spring-3-mvc-create-hello-world-application-spring-3-mvc.html and its very help full for start up development. but still i am finding another example so that i come to know more about it
if anybody knows some example in spring 3.0 then please provide me.
Thanks
Dhrumil Shah
These days, I think the easiest way to find out how to set up a spring application is by trying out Spring Roo. It may not be what you finally end up using when coding your project but it shows you exactly how to setup a Spring MVC web app.
I've also been looking all over for a full Spring MVC 3.0 tutorial with Eclipse that I could follow and haven't had too much luck in my research. The closest and most helpful example that I could find is here: http://krams915.blogspot.com/2011/01/spring-mvc-3-hibernate-annotations.html. This is also a maven project, but I was able to move some things around in my Dynamic Web Project within Eclipse and at least get the initial page to come up. Currently, I'm having issues with spring finding my controller class, but I think that's a part of changing the configuration files to meet my project needs. But try it and I hope it works for you!
I found these tutorials really helpful:
http://krams915.blogspot.ch/p/tutorials.html
I wanted to use REST and MongoDB and followed following tutorial with success:
http://krams915.blogspot.ch/2012/01/spring-mvc-31-implement-crud-with_4739.html
I hope it helps. I know how you feel :) Had the same issues. But it's worth sticking with Spring and learning it. It's a great framework once you know it.
Personally I made not so good experiences using Spring Roo. It can help you maybe a little bit for investigation how to setup a project but if you are new to Aspect Oriented Development you'll have a hard time figuring out what Spring Roo does. It can help you to setup a project really fast and easy but if you don't understand what's behind the facade it's hard working with it. This is not really for a beginner and no necessity for any project. But Aspect Oriented Development is worth wile learning and can be very useful to avoid boiler plate code.
Another route might be use appfuse, specifically using maven to generate the application template code from the appfuse archetype. E.g. this link.
There is a major difference in Spring 2.5 and Spring 3.x, Spring 3 or later introduces Annotations based bean wiring and dependency injection.
The nice step by step tutorial i found is http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial

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.

Best Eclipse Plugins for java development making use of spring/ struts /hibernate?

I am looking for plugins which make developer's life easy while using technologies like Struts/ Spring/ Hibernate. For instance, here is a requirement:
If I were to change an Struts Action, I should be able to list out all the Struts Actions for my webapp, right click and add a method/ do some changes.
So, basically, I need to know what plugins will make eclipse more 'technology/framework friendly'.
Appreciate your help!
I've heard good things about Spring IDE. It has support for the Spring basics plus a few associated libraries, and is available as an Eclipse plugin download from http://springide.org/updatesite/. Once installed, you apply a Spring nature to the project in order to use it.
Hibernate also has Hibernate Tools available, but I've never checked that out to see how it works. From the description, it apparently offers some functions to make creating and editing mapping files easier.
As far as I can tell, Struts doesn't have anything up-to-date as far as IDE plugins go. MyEclipse may have something like that.
Side note: for some reason, I've never stuck with the plugins for these libraries. I gave the Spring one a try once, but eventually got used to editing the Spring configs manually and haven't touched it in a while. I don't know how much of a benefit they would be for increasing config file creation... although they probably would help in visualizing dependencies in a big set of Spring configs.
Spring tools suite is great for this. You might also look into Fast Code Eclipse Plugin
If you don't mind paying the price ($31.75 for standard, $63.55 for pro), you could check out MyEclipse. This is a nice and powerful "extension" of Eclipse that has many nice features, including Spring Tools, Struts (and Struts 2), Hibernate and many more.

Categories