Easiest frameworks to implement Java REST web services in 2014

Kam*_*icz 5 java rest web-services jersey restlet

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

  • 开箱即用,但随着需求开始偏离默认值,迅速让开

  • 提供一系列大型项目通用的非功能特性(例如嵌入式服务器、安全性、指标、健康检查、外部化配置)

Spring Boot 不生成代码,完全不需要 XML 配置。

Bog*_* M. 3

玩!框架是另一种选择。

\n\n
\n

如果应用程序遵循主要 REST 设计原则,则该应用程序就是 RESTful。Play 框架可以轻松构建\n RESTful 应用程序:

\n\n

Play 路由器解释 URI 和 HTTP 方法以将请求路由到 Java 调用。基于正则表达式的 URI 模式为您提供了更大的灵活性。该协议是无状态的。这意味着您\n 无法在两个连续请求之间\xe2\x80\x99 保存服务器上的任何状态。\n Play 将HTTP 视为一项关键功能,因此该框架为您\n 提供了对HTTP 信息的完全访问权限。

\n
\n\n

http://www.playframework.com/documentation/1.2/routes

\n\n

如此相关:\n玩得RESTful!框架

\n\n

示例(来自https://www.openshift.com/blogs/day-30-play-framework-a-java-developer-dream-framework

\n\n
public class StoryController {\n\n    public static Result allStories(){\n        List<Story> stories = new Model.Finder<String , Story>(String.class, Story.class).all();\n        return Results.ok(Json.toJson(stories));\n    }\n\n    public static Result getStory(String storyId){\n        Story story = new Model.Finder<String, Story>(String.class, Story.class).byId(storyId);\n        if(story == null){\n            return Results.notFound("No story found with storyId " + storyId);\n        }\n        return Results.ok(Json.toJson(story));\n    }\n}\n
Run Code Online (Sandbox Code Playgroud)\n