使用open liberty-maven-plugin时如何设置委托parentLast?

问题描述 投票:0回答:1

我有两个应用程序需要将类加载器设置为 delegate="parentLast"。

一方面,我有一个不需要在它们之上开发的应用程序(称为sites.ear),我只是按原样使用它,所以我不需要将此EAR集成到我的IDE中。因此,我直接在我的 server.xml 上配置这个应用程序。

另一方面,我正在开发一个名为“博客”的应用程序。如果我在 server.xml 中设置以下行,它可以正常工作,但如果我这样做,我就不能不使用 liberty-maven-plugin(从 IDE 启动应用程序)。如果我尝试使用 IntelliJ 启动应用程序,那么它会部署代码两次,一次来自 server.xml,另一次由插件部署 (mvn liberty:run)

    <application id="app-blog" location="C:\Code\app-blog\target\app-blog.ear" name="wem-app-blog" type="ear">
        <classloader commonLibraryRef="global" delegation="parentLast"></classloader>
    </application>    

这是我在应用程序博客中配置的 pom.xml

<plugin>
  <groupId>io.openliberty.tools</groupId>
  <artifactId>liberty-maven-plugin</artifactId>
  <version>3.6</version>
  <configuration>
    <installDirectory>C:\wlp-webProfile8-21.0.0.12\wlp</installDirectory>
    <jvmOptionsFile>C:\wlp-webProfile8-21.0.0.12\wlp\usr\servers\defaultServer\jvm.arguments.txt</jvmOptionsFile>
  </configuration>
</plugin>

这是我的server.xml

<?xml version="1.0" encoding="UTF-8"?>
<server description="new server">

    <library id="global">
        <fileset dir="C:\sdk\libs-classpath" includes="*.jar"/>
    </library>

    <!-- Enable features -->
    <featureManager>
        <feature>webProfile-8.0</feature>
    </featureManager>

    <!-- To access this server from a remote client add a host attribute to the following element, e.g. host="*" -->
    <httpEndpoint id="defaultHttpEndpoint" host="*" httpPort="9080" httpsPort="9443"/>

    <!-- Automatically expand WAR files and EAR files -->
    <applicationManager autoExpand="true"/>

    <application id="sites" location="C:\sdk\websphere\sites.ear" name="sites" type="ear">
        <classloader commonLibraryRef="global" delegation="parentLast"></classloader>
    </application>
    
    <!-- Default SSL configuration enables trust for default certificates from the Java runtime --> 
    <ssl id="defaultSSLConfig" trustDefaultCerts="true" />
</server>

我也尝试过以全局方式将类加载器配置为parentLast,但是不起作用。

基本上,我想使用集成到我的 IDE IntelliJ 中的开放自由服务器,并且我想使用 IDE 启动和停止服务器。现在,我无法使用类加载器parentLast从IDE启动。

有没有办法与 IDE 集成,将类加载器部署到parentLast?

如有任何想法或建议,我们将不胜感激。

谢谢你

websphere maven-plugin open-liberty was classloading
1个回答
0
投票

解决方案:

使用与应用程序存档的“基本名称”仅匹配的“位置”来配置您的应用程序,例如:

<application id="app-blog" location="app-blog.ear" name="wem-app-blog" type="ear">
  <classloader commonLibraryRef="global" delegation="parentLast"/>
</application>    

注意: 如果您要部署工件以在文件名中包含版本,则可能需要调整此设置,可以在 server.xml 中添加版本或使用“stripVersion”配置参数)。

说明

Liberty Maven/Gradle 插件努力为通过插件部署的应用程序自动生成部署配置(直接通过 liberty-maven-plugin 的“部署”目标或作为“运行”或“运行”的一部分进行部署)开发目标)。

但是,如果您需要提供自己的非默认配置(例如父级最后类加载),并且您的配置与 Liberty Maven/Gradle 插件生成的配置不一致,这可能会导致问题。该插件最终可能会将您的配置视为不同应用程序的配置,并认为它需要继续生成自己的配置,现在您有一个应用程序的两个配置,并且只有一个具有正确的属性、自定义等等

注意: 我也会在最新的 liberty-maven-plugin 版本(v3.9)上尝试这个,因为过去几年我们在这方面进行了一些修复。

© www.soinside.com 2019 - 2024. All rights reserved.