简体   繁体   English

Spring 作为战争引导与 jar

[英]Spring boot as war vs jar

We are developing a middleware platform with Spring-boot and REST and we are NOT going to fully microservice architecture, but creating small services based on functionality.我们正在开发一个带有 Spring-boot 和 REST 的中间件平台,我们不会完全采用微服务架构,而是基于功能创建小型服务。 Eg: catalog-service-api is for CRUD operations on the catalog and online-services-api for IoT.例如:catalog-service-api 用于目录上的 CRUD 操作,online-services-api 用于 IoT。

1. Should I go for war or jar? 1. 我应该为战争使用 go 还是 jar?

I feel the disadvantage of jar here is, each jar creates a new process (new tomcat) which I don't want to scale at this moment.我觉得 jar 的缺点是,每个 jar 都会创建一个新进程(新的 tomcat),此时我不想扩展。

As we are developing a cloud-based enterprise product, Do we need jar OR war?当我们正在开发基于云的企业产品时,我们需要 jar 还是战争? Microservices NOT required.不需要微服务。

2. If I go with war, is spring boot admin will work as expected? 2. 如果我 go 与战争,是 spring 启动管理员会按预期工作吗?

We are facing deploying spring-boot admin in one server and the client is another server.我们正面临在一台服务器上部署 spring-boot 管理员,而客户端是另一台服务器。

@SpringBootApplication
@EnableAutoConfiguration
@EnableAdminServer
public class SpringBootAdminServerApplication extends 
SpringBootServletInitializer{

public static void main(String[] args) {
    SpringApplication.run(SpringBootAdminServerApplication.class, args);
}
}

Client:客户:

@SpringBootApplication
public class SpringBootAdminClientApplication extends 
SpringBootServletInitializer{

    public static void main(String[] args) {
        SpringApplication.run(SpringBootAdminClientApplication.class, args);
    }
 }

client application.properties: spring.boot.admin.client.url= http://localhost:8085 spring.boot.admin.client.service-url= http://localhost:8085/spring-boot-admin-server client application.properties: spring.boot.admin.client.url= http://localhost:8085 spring.boot.admin.client.service-url= http://localhost:8085/spring-boot-admin-server

Admin server is running but client is not available.管理服务器正在运行,但客户端不可用。

Please suggest.请建议。

Should I go for war or jar?我应该为战争使用 go 还是 jar?

That choice solely depends on you.这个选择完全取决于你。 I think if you understand basic difference you will understand that.我认为,如果您了解基本区别,您就会明白这一点。 See below:见下文:

A.war file is a Web Application Archive which runs inside an application server while a.jar is Java Application Archive that runs a desktop application on a user's machine. A.war 文件是Web 应用程序存档,它在应用程序服务器内运行,而 a.jar 是Java 应用程序存档,在用户机器上运行桌面应用程序。

So, if you want multiple applications running under same application server choose war.因此,如果您希望在同一应用服务器下运行多个应用程序,请选择 war。 Though trend is to have jar files having 0 sever configuration & capable of running anywhere (eg springbooot fat-jar).虽然趋势是让 jar 文件具有 0 服务器配置并且能够在任何地方运行(例如 springboot fat-jar)。

If I go with war, is spring boot admin will work as expected?如果我与 go 发生战争,spring 启动管理员是否会按预期工作? It's your applications and server and other settings of machine, a war or jar type have nothing to do with it.它与你的应用程序和服务器等机器的设置,一战或jar类型无关。

I suggest that you should go for Spring Boot application with JAR with docker containers.我建议您应该 go 用于 Spring 启动应用程序与 JAR 与 Z05B6053C41A2130AFDZ6FC63E 容器。

  • What happens if one of your project leaks memory or CPU, is that mean your tomcat will fail?如果您的项目之一泄漏 memory 或 CPU 会发生什么,这是否意味着您的 tomcat 将失败?
  • What happens if you need to restart one of your project?如果您需要重新启动您的项目之一,会发生什么?

On the other hand, if your projects are depend on each other you might want to use war.另一方面,如果您的项目相互依赖,您可能需要使用 war。

There is no better approach, it depends on project and your knowledge of devOps for docker.没有更好的方法,这取决于项目和您对 docker 的 devOps 的了解。 Personally, i run all my projects with Jar for seperate processes with or without docker.就我个人而言,我使用 Jar 运行我所有的项目,用于单独的进程,有或没有 docker。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM