0

我正在尝试在我的 SpringBoot 应用程序上实现扩展功能,其中 @ComponentScan 应该扫描类路径中存在的单独 jar 中的 bean 定义。

@ComponentScan 如下所示

@ComponentScan({"com.myapp.rest","com.mycompany.search.rest"})

其中包“com.mycompany.search.rest”将出现在外部 jar ESExt.jar 中

我在 WebSphere Liberty Server 的文件中添加了以下配置,server.xml以包含用于类路径扫描的外部文件夹

<library id="extention" apiTypeVisibility="+third-party, -api">
  <fileset dir="${server.config.dir}/ext" includes="*.jar" scanInterval="5s" />
</library>

<webApplication id="Myapp" location="Myapp.war" type="war" name="Myapp" contextRoot="/resources">
    <classloader commonLibraryRef="extention" />
</webApplication>

当我在 WebSphere Liberty Server 中部署我的应用程序时,它会抛出以下异常

[28/9/20 13:43:04:878 IST] 0000002a com.ibm.ws.logging.internal.impl.IncidentImpl                I FFDC1015I: An FFDC Incident has been created: "org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'storeResource': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [com.mycompany.search.rest.StoreResource] from ClassLoader [com.ibm.ws.classloading.internal.AppClassLoader@7a84a757] com.ibm.ws.webcontainer.osgi.DynamicVirtualHost startWebApp" at ffdc_20.09.28_13.43.04.0.log

下面是输出jar -tf ESExt.jar

META-INF/
META-INF/MANIFEST.MF
com/
com/mycompany/
com/mycompany/search/
com/mycompany/search/rest/
com/mycompany/search/rest/StoreResource.class

这个例外IllegalStateException: Failed to introspect Class甚至意味着什么?我什至无法在互联网上找到任何关于它的信息。

4

1 回答 1

0

通过更改server.xml如下解决它

<library id="extension">
    <fileset dir="${server.config.dir}/ext" includes="*.jar" scanInterval="5s" />
</library>
    
<webApplication id="Myapp" location="Myapp.war" type="war" name="Myapp" contextRoot="/resources">
    <classloader commonLibraryRef="extension" delegation="parentFirst"/>
</webApplication>
于 2020-09-29T09:35:43.903 回答