jboss( WildFly)上运行 springboot程序

WildFly,原名 JBoss AS(JBoss Application Server) 或者 JBoss,是一套应用程序服务器,属于开源的企业级 Java 中间件软件,用于实现基于 SOA 架构的 Web 应用和服务。 WildFly 包含一组可独立运行的软件。

WildFly采用积极的方法进行内存管理。开发基本运行时服务是为了最大程度地减少堆分配。这些服务在重复的完整解析中使用公共的缓存索引元数据,从而减少了堆和对象的流失。模块化类加载的使用可防止重复类和加载超出系统配置要求的类。这不仅减少了基本内存开销,而且还有助于最大程度地减少垃圾收集器的暂停。最后,管理控制台是100%无状态的,并且完全由客户端驱动。它会立即启动,并且需要服务器上的零内存。

下面我们说一下主要的实现方式和步骤:

1. war的依赖

需要添加war的打包方式,<packaging>war</packaging>

<plugin>

  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-war-plugin</artifactId>
  <configuration>
      <failOnMissingWebXml>false</failOnMissingWebXml>
      <archive>
          <manifestEntries>
              <Dependencies>jdk.unsupported</Dependencies>
          </manifestEntries>
      </archive>
  </configuration>
</plugin>

2. tomcat使用WildFly提供的

需要先排除springboot web里的tomcat,然后使用provider级别的tomcat,即wildfly里的

<dependency>
  <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-web</artifactId>
   <exclusions>
      <exclusion>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-tomcat</artifactId>
      </exclusion>
   </exclusions>
 </dependency>

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>
  1. 定义Dockerfile文件
    Dockerfile里,我们使用Jboss的镜像,它对于应用程序来说,是一个托管的环境,支持热部署
FROM jboss/wildfly
ADD target/a-start-hot-deploy.war /opt/jboss/wildfly/standalone/deployments/demo.war

运行之后的效果如下:
1
访问地址为:`http://localhost:8080/demo`,其中demo为应用程序的名称

原文地址:https://www.cnblogs.com/lori/p/14406441.html