简体   繁体   English

无法在WebSphere上运行的SpringBoot应用程序中找到Webjars

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

I have been trying to host Spring Boot application on WebSphere server. 我一直在尝试在WebSphere服务器上托管Spring Boot应用程序。

Versions : 版本:

  • SpringBoot 2.1.6.RELEASE SpringBoot 2.1.6。发布
  • WebSphere Liberty 19.0.0.6 with JavaEE 8 具有JavaEE 8的WebSphere Liberty 19.0.0.6
  • webjars-locator 0.36 webjars定位器0.36

The app was successfuly deployed on standalone Tomcat 9.0.22 and webjars could be resolved there. 该应用程序已成功部署在独立的Tomcat 9.0.22上,可以在那里解决webjars。 However for WebSphere I receive an error when trying to access webjars from html page : 但是对于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

And the webjars pattern was successfuly mapped by Spring : Spring成功映射了webjars模式:

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

The solution for this is to add classloading entry, with useJarUrls attribute set to true , to WebSphere server.xml file : 解决方案是向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>

This IBM support issue was particulary helpful in solving this problem. 这个IBM support issue特别有助于解决此问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM