Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring boot 使用Liberty为web应用程序定义类加载器_Spring Boot_Websphere Liberty - Fatal编程技术网

Spring boot 使用Liberty为web应用程序定义类加载器

Spring boot 使用Liberty为web应用程序定义类加载器,spring-boot,websphere-liberty,Spring Boot,Websphere Liberty,我有一个应用程序Rest服务,这是一场战争,我想在Liberty配置文件中部署它。目前,我正在打包该应用程序以及所有SpringJAR内部战争。 但我们希望创建一个共享库,并将所有这些jar移动到共享库中,并使用应用程序中的类加载器引用该共享库 server.xml <application location ="restapp-1.0.0-SNAPSHOT.war" context-root="/myrestapp/mytestapp"> <classload

我有一个应用程序Rest服务,这是一场战争,我想在Liberty配置文件中部署它。目前,我正在打包该应用程序以及所有SpringJAR内部战争。 但我们希望创建一个共享库,并将所有这些jar移动到共享库中,并使用应用程序中的类加载器引用该共享库

server.xml
<application location ="restapp-1.0.0-SNAPSHOT.war" context-root="/myrestapp/mytestapp">
        <classloader commonLibraryRef="global"/>
    </application>

    <library id="global">
        <fileset includes="*.jar" dir="${server.config.dir}/lib/global"></fileset>
    </library>

Also I have placed all the jar dependencies under server/config/lib/global.

I am having below entries in my ibm-web-ext.xml which is in webapp/WEB-INF/

<web-ext
    xmlns="http://websphere.ibm.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://websphere.ibm.com/xml/ns/javaee http://websphere.ibm.com/xml/ns/javaee/ibm-web-ext_1_0.xsd"
    version="1.0">


    <reload-interval value="3"/>
    <context-root uri="/myrestapp/mytestapp" />
    <enable-directory-browsing value="false"/>
    <enable-file-serving value="true"/>
    <enable-reloading value="true"/>
    <enable-serving-servlets-by-class-name value="false" />

</web-ext>


Same config is working fine if I bundle all the jar's as part of WAR and place the war in dropins folder. But Sharedlibrary configuration is not working.
server.xml
我还将所有jar依赖项放在server/config/lib/global下。
我在webapp/web-INF中的ibm-web-ext.xml中有以下条目/
如果我将所有jar打包为WAR的一部分,并将WAR放在dropins文件夹中,那么相同的配置也可以正常工作。但Sharedlibrary配置不起作用。

通过在server.xml中放置以下配置,可以在WebSphere Liberty中为应用程序定义共享库:

<library id="springLib">
 <fileset dir="${server.config.dir}/libs/spring/" includes="*.jar"/>
</library>

<application location ="restService.war">
  <classloader commonLibraryRef="springLib"/>
</application>


如果我正确理解了您的问题,您想使用自己的自定义类加载器加载共享库吗?如果我的理解是正确的,那就没有办法了。至少不使用标准的server.xml配置。@aguibert我需要在应用程序中定义一个类加载器来加载共享库。它不是自定义类加载器。当我们将应用程序构建为ear时,我们在deployment.xml中定义了sharedLib和类加载器。但我不知道如何在带有Liberty profile的war文件中定义它。这应该是
而不是
。这看起来像是知识中心主题中的一个错误。@aguibert我正在使用下面的配置,但由于某些原因,它对我不起作用。重新阅读您的问题时,您提到您认为全局库指向$wlp_home/usr/servers/server/config/lib/global。请注意${server.config.dir}是服务器的目录(server.xml所在的目录)。鉴于此,您的库是否指向有效目录?