在Java中创建RESTful API服务器需要什么?

时间:2023-01-24 13:15:03

I would like to build my own RESTful API Server and I have no idea what I need for that.

我想构建自己的RESTful API服务器,我不知道我需要什么。

I'll tell you a bit about the project:

我会告诉你一些关于这个项目的信息:

On a Webservice (www.mysite.com/) users can register and manage their account and so on. But they also can use the RESTful API (mysite.com/api/...) and can do there pretty much the same via REST.

在Webservice(www.mysite.com/)上,用户可以注册和管理他们的帐户等。但他们也可以使用RESTful API(mysite.com/api / ...),并且可以通过REST实现相同的功能。

What is a good way to realize that? Do I need to use jetty or something similar? Should I split web service and restful api ? what I a good architecture for that?

实现这一目标的好方法是什么?我需要使用码头或类似的东西吗?我应该拆分Web服务和restful api吗?我的建筑是什么?

Thanks :)

谢谢 :)

5 个解决方案

#1


12  

you can use Spring controller for build a restful server. You can run it on tomcat or jetty doesn't matter.

您可以使用Spring控制器构建一个安静的服务器。你可以在tomcat或jetty上运行它并不重要。

check this url : http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html

检查此网址:http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html

#2


4  

Tomcat and Jersey are easy to get up and running. I've had some issues with Tomcat 7 and Jersey, but with Tomcat 6 it was straight forward.

Tomcat和Jersey很容易启动和运行。我在Tomcat 7和Jersey方面遇到了一些问题,但是对于Tomcat 6来说,它是直截了当的。

This tutorial is quite easy to follow. It's a bit old, but the principle remains the same.

本教程很容易理解。它有点旧,但原则仍然相同。

#3


3  

IBM provides good set of information and tutorials about building RESTful web service with Java (Link). After getting your web service running, you can deploy it to Amazon. Take a look at AWS Elastic Beanstalk.

IBM提供了一套有关使用Java(Link)构建RESTful Web服务的良好信息和教程。让您的Web服务运行后,您可以将其部署到Amazon。看看AWS Elastic Beanstalk。

#4


1  

I found a simple example at http://coder2design.com/rest-web-services/ to build a REST application.

我在http://coder2design.com/rest-web-services/找到了一个简单的例子来构建一个REST应用程序。

  • XML Schema(xsd) is used to build domain classes.
  • XML Schema(xsd)用于构建域类。
  • Eclipse EE is used as IDE and Maven for building.
  • Eclipse EE用作IDE和Maven进行构建。
  • Jersey as a framework for REST
  • 泽西岛作为REST的框架
  • Hibernate for persistence layer.
  • Hibernate用于持久层。
  • MySQL as DB
  • MySQL作为DB

All other configurations are nicely explained.

所有其他配置都很好地解释。

#5


1  

In 2017 one of the best solutions would be to use spring boot. Gives you great effects without writing tons of code.

2017年,最好的解决方案之一就是使用弹簧靴。无需编写大量代码即可获得出色的效果。

@RestController
public class HelloController {

    @RequestMapping("/")
    public String index() {
        return "Greetings from Spring Boot!";
    }

}

#1


12  

you can use Spring controller for build a restful server. You can run it on tomcat or jetty doesn't matter.

您可以使用Spring控制器构建一个安静的服务器。你可以在tomcat或jetty上运行它并不重要。

check this url : http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html

检查此网址:http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch18s02.html

#2


4  

Tomcat and Jersey are easy to get up and running. I've had some issues with Tomcat 7 and Jersey, but with Tomcat 6 it was straight forward.

Tomcat和Jersey很容易启动和运行。我在Tomcat 7和Jersey方面遇到了一些问题,但是对于Tomcat 6来说,它是直截了当的。

This tutorial is quite easy to follow. It's a bit old, but the principle remains the same.

本教程很容易理解。它有点旧,但原则仍然相同。

#3


3  

IBM provides good set of information and tutorials about building RESTful web service with Java (Link). After getting your web service running, you can deploy it to Amazon. Take a look at AWS Elastic Beanstalk.

IBM提供了一套有关使用Java(Link)构建RESTful Web服务的良好信息和教程。让您的Web服务运行后,您可以将其部署到Amazon。看看AWS Elastic Beanstalk。

#4


1  

I found a simple example at http://coder2design.com/rest-web-services/ to build a REST application.

我在http://coder2design.com/rest-web-services/找到了一个简单的例子来构建一个REST应用程序。

  • XML Schema(xsd) is used to build domain classes.
  • XML Schema(xsd)用于构建域类。
  • Eclipse EE is used as IDE and Maven for building.
  • Eclipse EE用作IDE和Maven进行构建。
  • Jersey as a framework for REST
  • 泽西岛作为REST的框架
  • Hibernate for persistence layer.
  • Hibernate用于持久层。
  • MySQL as DB
  • MySQL作为DB

All other configurations are nicely explained.

所有其他配置都很好地解释。

#5


1  

In 2017 one of the best solutions would be to use spring boot. Gives you great effects without writing tons of code.

2017年,最好的解决方案之一就是使用弹簧靴。无需编写大量代码即可获得出色的效果。

@RestController
public class HelloController {

    @RequestMapping("/")
    public String index() {
        return "Greetings from Spring Boot!";
    }

}