Vaadin 应用程序和 React 在同一服务器上。

huangapple go评论83阅读模式
英文:

Vaadin application and react in the same server

问题

我有些困惑,不知道该使用哪个服务器来同时容纳 Vaadin 应用(Java)和 React 应用。
之前我在使用 Node.js 来容纳我的 React 应用,现在我开发了 Vaadin 应用(我使用了 Jetty 进行测试),但我想将它们合并在同一个服务器上。

  1. 我可以使用 Tomcat 来同时容纳它们吗?如何在 Tomcat 上部署 React?
  2. 我可以使用 Express.js 来同时容纳它们吗?如何在 Express.js 上部署 Vaadin?
  3. 有更好的方法吗?

非常感谢。

英文:

I'm a bit confused about what server to use for contain both, a Vaadin application (java) and a react application.
I was using nodejs for contain my react app, now I developed my vaadin application (I've used jetty to test it out), but I want to combined them in the same server

  1. Can I use Tomcat to contain both? How can I deploy React on Tomcat?
  2. Can I use expressJs to contain both? How can I deploy Vaadin on expressJs?
  3. Is there a better approach?

Thank you a lot.

答案1

得分: 2

你在某种程度上正在将苹果与橙子进行比较。直接回答你的问题:你可以在两者中都使用Tomcat,但不能在Express.js中使用。

  • Vaadin是一个倾向性的全栈框架。它明确涵盖了在服务器上运行的用户界面部分和在浏览器中运行的部分。服务器部分只能在JVM上工作,可以通过诸如Tomcat的servlet容器或者使用嵌入式servlet容器(如Spring Boot)将其部署为独立进程。
  • React是一个相对不偏不倚的客户端框架 - 它明确设计用于与任何服务器端技术配合使用。它通常与服务器端JavaScript(如Express.js)一起使用,因为这样可以让整个应用程序只使用一种语言来实现,但它也经常与使用Java或C#运行的后端一起使用。服务器端所需的只是一种创建用于访问后端逻辑的端点的方法。对于Java而言,目前最常见的解决方案是使用Spring(无论是MVC还是WebFlux)或JAX-RS(如Jersey)来创建REST端点。
英文:

You're to some degree comparing apples to oranges in this case. To directly answer you question: You can use Tomcat for both, but not Express.js.

  • Vaadin is an opinionated full stack framework. It explicitly covers both the part of the UI that runs on the server and the part that runs in the browser. The server part only works on the JVM, either through a servlet container such as Tomcat or deployed as a standalone process with an embedded servlet container using e.g. Spring Boot.
  • React a relatively agnostic client-side framework - it is explicitly designed to work with any server-side technology. It is often used together with server-side JavaScript (e.g. Express.js) because that allows the whole application to be implemented using only one language, but it is also very commonly used with a backend running with e.g. Java or C#. All you need on the server is a way of creating endpoints for accessing the backend logic. In the case of Java, the two most common solution nowadays is to do REST endpoints using Spring (either MVC or WebFlux) or JAX-RS (e.g. Jersey).

huangapple
  • 本文由 发表于 2020年4月11日 09:20:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/61150950.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定