TongWeb支持Spring Boot、Spring Cloud说明

问:TongWeb支持Spring Boot,Spring  Cloud吗?

答:主要看Spring Boot各个版本需要的JavaEE的web容器规范是多少,而Spring Cloud 构建于 Spring Boot 之上,也是看Spring Boot。

应用用Spring Boot2.x则用TongWeb7版本,下图为Spring官方对容器的要求。

TongWeb支持Spring Boot、Spring Cloud说明_第1张图片

应用用Spring Boot1.5.x则可用TongWeb6.1/7.0版本,下图为官方对容器的要求。

TongWeb支持Spring Boot、Spring Cloud说明_第2张图片

但是有些应用框架采用Spring Boot+Spring WebFlux方式,可以运行在非servlet容器上,采用netty线程池,这种使用方式也就不存在TongWeb替换tomcat、jetty的需求了,除非netty也列为必须替换的开源组件。

TongWeb支持Spring Boot、Spring Cloud说明_第3张图片

Spring 官网说明:

1.1.5. Servers

Spring WebFlux is supported on Tomcat, Jetty, Servlet 3.1+ containers, as well as on non-Servlet runtimes such as Netty and Undertow. All servers are adapted to a low-level, common API so that higher-level programming models can be supported across servers.

Spring WebFlux does not have built-in support to start or stop a server. However, it is easy to assemble an application from Spring configuration and WebFlux infrastructure and run it with a few lines of code.

Spring Boot has a WebFlux starter that automates these steps. By default, the starter uses Netty, but it is easy to switch to Tomcat, Jetty, or Undertow by changing your Maven or Gradle dependencies. Spring Boot defaults to Netty, because it is more widely used in the asynchronous, non-blocking space and lets a client and a server share resources.

Tomcat and Jetty can be used with both Spring MVC and WebFlux. Keep in mind, however, that the way they are used is very different. Spring MVC relies on Servlet blocking I/O and lets applications use the Servlet API directly if they need to. Spring WebFlux relies on Servlet 3.1 non-blocking I/O and uses the Servlet API behind a low-level adapter. It is not exposed for direct use.

For Undertow, Spring WebFlux uses Undertow APIs directly without the Servlet API.

Spring Boot、SpringCloud项目支持war包和jar包两种方式部署:

1. TongWeb6、7企业版/标准版支持以war包方式部署。

2. TongWeb7.0.E.x嵌入版支持以jar包方式部署。

当看到以下日志图标时表示Spring Boot启动。

TongWeb支持Spring Boot、Spring Cloud说明_第4张图片

注:在TongWeb上部署Spring Boot项目前,请先把应用lib下的tomcat*.jar相关jar清理干净,否则会看到各种在TongWeb中启动tomcat的错误。如下:

The Apache Tomcat Native library failed to load.The error reported was [java.lang.UnsatisfiedLinkError:Native Library /opt/tongweb/native/linux/aarch64/libtcnative-1.so already loaded in another classloader.

附:TongWeb7.0.E.x嵌入版打包示例


  4.0.0
  1.0.0
  springboot-tw
  1
  jar
  springboot-tw
  http://maven.apache.org
  
    UTF-8
    1.8
  
   
		org.springframework.boot
		spring-boot-starter-parent
		2.3.8.RELEASE
		 
	
   
      
            org.springframework.boot
            spring-boot-starter-web
			
			
              
              org.springframework.boot
              spring-boot-starter-tomcat
              
			
      
	  
	  
           com.tongweb.springboot
           tongweb-spring-boot-starter
           2.x.0.RELEASE
      
      
           com.tongweb
           tongweb-embed
           7.0.E.1
           
      
			org.springframework.boot
			spring-boot-starter-test
			test
	  
  
  
        
            
                org.springframework.boot
                spring-boot-maven-plugin
                
                    com.tong.App
                
            
        
    

你可能感兴趣的:(web,spring,boot,java)