a lot of frameworks on the JVM platform have grown big and in my opinion a bit messy. Some J2EE projects I was involved in had almost as many configuration files as source code files. Sure, one can argue that’s always up to the developer but I tend to prefer framework and tools with a clear structure and maybe even some borders to make sure everyone uses the same style and architecture
What are the best frameworks for implementing server REST + website frameworks in Java? I've been struggling a little to find an easy to use solution.
Jersey and Restlet seem like good options, but I read the old threads, before learning Restlet the will to make sure there are no significant new tools?
I want to create a simple REST API(for android) and website
Update 2017-01-26: After two years, I can confidently admit that Spring Boot is what I was looking for
Spring Boot aims to make it easy to create Spring-powered, production-grade applications and services with minimum fuss. It takes an opinionated view of the Spring platform so that new and existing users can quickly get to the bits they need. You can use it to create stand-alone Java applications that can be started using ‘java -jar’ or more traditional WAR deployments. We also provide a command line tool that runs ‘spring scripts’.
The diagram below shows Spring Boot as a point of focus on the larger Spring ecosystem. It presents a small surface area for users to approach and extract value from the rest of Spring:
Spring Boot in Context
The primary goals of Spring Boot are:
To provide a radically faster and widely accessible ‘getting started’ experience for all Spring development
To be opinionated out of the box, but get out of the way quickly as requirements start to diverge from the defaults
Spring Boot does not generate code and there is absolutely no requirement for XML configuration.
Play! framework is another option.
If an application follows the main REST design principles, the application is RESTful. The Play framework makes it easy to build RESTful applications:
The Play router interprets both URI and HTTP methods to route a request to a Java call. Regular expressions-based URI patterns give you even more flexibility. The protocol is stateless. This means you can’t save any state on the server between two successive requests. Play considers HTTP as a key feature, thus the framework gives you full access to HTTP information.
http://www.playframework.com/documentation/1.2/routes
SO related: RESTful on Play! framework
Example(from https://www.openshift.com/blogs/day-30-play-framework-a-java-developer-dream-framework)
public class StoryController {
public static Result allStories(){
List<Story> stories = new Model.Finder<String , Story>(String.class, Story.class).all();
return Results.ok(Json.toJson(stories));
}
public static Result getStory(String storyId){
Story story = new Model.Finder<String, Story>(String.class, Story.class).byId(storyId);
if(story == null){
return Results.notFound("No story found with storyId " + storyId);
}
return Results.ok(Json.toJson(story));
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With