簡體   English   中英

無法在WebSphere上運行的SpringBoot應用程序中找到Webjars

[英]Cannot locate webjars with SpringBoot application running on WebSphere

我一直在嘗試在WebSphere服務器上托管Spring Boot應用程序。

版本:

  • SpringBoot 2.1.6。發布
  • 具有JavaEE 8的WebSphere Liberty 19.0.0.6
  • webjars定位器0.36

該應用程序已成功部署在獨立的Tomcat 9.0.22上,可以在那里解決webjars。 但是對於WebSphere,當嘗試從html頁面訪問webjar時收到錯誤消息:

2019-08-05 10:43:11.839 DEBUG 1 --- [ecutor-thread-6] o.s.web.servlet.DispatcherServlet        : GET "/appcontext/webjars/jquery/jquery.min.js", parameters={}
2019-08-05 10:43:11.845 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.handler.SimpleUrlHandlerMapping  : Mapped to ResourceHttpRequestHandler ["classpath:/META-INF/resources/webjars/"]
2019-08-05 10:43:11.849 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.r.ResourceHttpRequestHandler     : Resource not found
2019-08-05 10:43:11.849 DEBUG 1 --- [ecutor-thread-6] o.s.web.servlet.DispatcherServlet        : Completed 404 NOT_FOUND

Spring成功映射了webjars模式:

2019-08-05 10:43:09.039 DEBUG 1 --- [ecutor-thread-6] o.s.w.s.handler.SimpleUrlHandlerMapping  : Patterns [/webjars/**, /**] in 'resourceHandlerMapping'

解決方案是向WebSphere server.xml文件中添加useJarUrls屬性設置為true classloading條目:

<server description="myServer">
    <featureManager>
        <feature>servlet-3.0</feature>
    </featureManager>
    <classloading useJarUrls="true"/> <!-- this line was added -->
    <httpEndpoint httpPort="9080" httpsPort="9443" host="*" id="defaultHttpEndpoint"/>
</server>

這個IBM support issue特別有助於解決此問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM