views:

332

answers:

3

I can't get spring annotations to work at all, I'm just trying to get the simplest thing to work...

.../mycontext/something -> invokes method:

@RequestMapping(value = "/something")
@ResponseBody
public String helloWorld() {
    System.out.println("hello world");
    return "Hello World";
}

My main problem is no matter how hard I try, I can't find a complete SIMPLE example of the configuration files needed, every spring tutorial is filled with junk, I just one one controller to handle a request with a mapping and can't get it to work

does anyone know of a simple and complete spring example. pet-clinic is no good, it's way too complicated, I have a tiny basic use case and it's proving to be a real pain to get working (this always happens with Spring)

+2  A: 

You should try Spring Roo. It will generate a simple Spring application for you using simple commands and then you can incrementally extend it. It is a great tool for learning Spring as well as for rapid application development.

You can also find several examples of Spring 3.0 MVC framework at https://src.springframework.org/svn/spring-samples/

Eugene Kuleshov
Between Roo acting as training wheels, and the Spring tutorials on the Spring site, jboyd should be good to go. jboyd, you still have to add the spring filter in your web.xml and then have your *-context.xml files, Roo can help get started with that.
mezmo
A: 

I'd recommend you checkout some of projects from here :

http://www.springbyexample.org/maven/site/spring-by-example-util/1.2/source-repository.html

and try going trough book spring in action(manning) they give very good example on how to use aspects

or refer to this post :

http://stackoverflow.com/questions/2560210/learning-spring-mvc-for-web-projects/2560296#2560296

c0mrade
+3  A: 

Hello, the absolute simplest alternative if you're familiar with Eclipse is to use SpringSource Tool Suite (Eclipse plugins)

This product has a tcServer bundled inside.

By default, STS will start with "dashboard" page in the editor window. From here, you can click on creating a controller as demonstrated by this screenshot:

alt text

This is a quite simple controller and all you have to do to get it deployed on the bundled tcServer (Tomcat with some extra management features) is to click "next" a few times in the wizard.

That's a very good starting point for doing your own testing!

Espen
@Espen +1 nice one
c0mrade