【问题标题】:Run two war instances in the same server.xml config在同一个 server.xml 配置中运行两个战争实例
【发布时间】:2019-02-01 09:41:53
【问题描述】:

我已经生成了两个具有不同属性 (DB) 的 Spring Boot (1.5.10.RELEASE) (war) 实例, 我的问题是要在 WebSphere Liberty Core 8.5 中运行这两个具有相同端口但具有不同上下文的实例?

我的 server.xml :

<httpEndpoint id="defaultHttpEndpoint"
                  host="*"
                  httpPort="9081"
                  httpsPort="9443"/>

<!-- A application -->
 <webApplication id="A"  location="A-0.0.1-SNAPSHOT.war"  contextRoot="/interactioncorpcontext-a"/>

<!-- B application -->
<webApplication id = "B" location="B-0.0.1-SNAPSHOT.war"  contextRoot="/interactioncorpcontext-b"/>

结果:

**http://hostname:9081/interactioncorpcontext-a**

**http://hostname:9081/interactioncorpcontext-b**

【问题讨论】:

    标签: spring-boot websphere-liberty websphere-8


    【解决方案1】:

    我发现一个解决方案是创建两个战争模块的 EAR:

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
        <modelVersion>4.0.0</modelVersion>
        <artifactId>ear</artifactId>
        <packaging>ear</packaging>
        <name>${project.artifactId}</name>
        <version>0.0.1-SNAPSHOT</version>
    
            <parent>
            <groupId>a.b.c</groupId>
            <artifactId>AP00959-starter-parent</artifactId>
            <version>1.5.10-SNAPSHOT</version>
        </parent>
    
        <dependencies>
    <!--        Project dependencies -->
            <dependency>
                <groupId>a.b.c</groupId>
                <artifactId>CCS</artifactId>
                <version>0.0.1-SNAPSHOT</version>
                  <type>war</type>
            </dependency>
    
                    <dependency>
                <groupId>a.b.c</groupId>
                <artifactId>mael</artifactId>
                <version>0.0.1-SNAPSHOT</version>
                  <type>war</type>
            </dependency>
    
        </dependencies>
    
    
    
            <build>
            <plugins>
    
    
      <plugin>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.10.1</version>
            <configuration>
                    <modules>
                            <webModule>
                                    <groupId>a.b.c</groupId>
                                    <artifactId>CCS1FRD0</artifactId>
                                    <contextRoot>/interactioncorpcontext-ccs</contextRoot>
                            </webModule>
                            <webModule>
                                    <groupId>a.b.c</groupId>
                                    <artifactId>mael</artifactId>
                                    <contextRoot>/interactioncorpcontext-mael</contextRoot>
                            </webModule>
                    </modules>
            </configuration>
          </plugin>
    
            </plugins>
        </build>
    
    
    
    
    
    </project>
    

    还要禁用 jmx 端点:

    endpoints:
       jmx:
         enabled: false
    

    【讨论】:

    • 为什么这是必要的?您的问题中的配置有什么问题?
    • 因为有在同一个端口上运行!
    • 似乎初始配置也会在“同一个端口”上运行。
    • 是的,这里的主要目的是在同一台服务器上运行两个数据库实例,具有相同的端口但具有不同的上下文,当然还有不同的参数。
    猜你喜欢
    • 1970-01-01
    • 2019-12-04
    • 2017-10-21
    • 1970-01-01
    • 2021-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    相关资源
    最近更新 更多