部署到 JBoss 的 Spring Boot Web 应用程序 - webjars-locator 似乎不起作用

Bri*_*ith 5 jboss webjars spring-boot

我有一个使用 Spring Boot 1.40 的小型 Web 应用程序,但我在使用 webjars-locator 时遇到了一些问题。当使用嵌入式 Tomcat 在我的机器上运行时,webjars-locator 按预期工作,我可以访问例如。带有以下 HTML 的 jQuery:

<script src="/webjars/jquery/jquery.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

但是,当应用程序打包为 .war 文件并部署到 JBoss 6.4.5 时,相同的 HTML 不再有效。尝试使用该 URL 直接访问浏览器中的 .js 文件会导致 404。但是我可以使用

<script src="/webjars/jquery/1.11.3/jquery.min.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)

并且文件将被找到,一切都很好。在 JBoss 上运行应用程序时,我看到一个可能相关的日志条目:

2016-08-20 02:01:01.154 WARN  o.s.w.s.r.ResourceHttpRequestHandler - Locations list is empty. No resources will be served unless a custom ResourceResolver is configured as an alternative to PathResourceResolver.
Run Code Online (Sandbox Code Playgroud)

我猜在 JBoss 中运行时我需要专门配置一些在嵌入式 Tomcat 中“正常工作”的东西;如果有人能指出我正确的方向,那就太好了。

必须指定 webjar 的版本对于这个特定的应用程序来说不是一个交易破坏者,但如果我们需要升级 jQuery 或其他东西,在更大的应用程序中可能是一个巨大的痛苦。

Jam*_*ard 5

有关上下文,请参阅:https : //github.com/webjars/webjars-locator/issues/18

您可能只需要添加以下依赖项:

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>webjars-locator-jboss-vfs</artifactId>
    <version>0.1.0</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)