vert.x - Webjars 不适用于 vert.x 应用程序
问题描述
在 vert.x 应用程序中配置 webjars 的正确方法是什么?我有这个简单的应用程序:
class WebVerticle : CoroutineVerticle() {
override suspend fun start() {
val router = Router.router(vertx)
// Serve static resources from the /assets directory
router.route("/").handler(StaticHandler.create())
val json = ConfigRetriever.create(vertx).getConfigAwait()
val port = json.getInteger("port")
try {
vertx.createHttpServer().requestHandler(router).listenAwait(port)
println("HTTP server started on port $port - redeploy enabled")
} catch (ex: Exception) {
error("Could not spawn web server at port $port")
}
}
}
pom.xml
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
<version>${vertx.version}</version>
</dependency>
<dependency>
<groupId>org.webjars</groupId>
<artifactId>vue</artifactId>
<version>2.5.16</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>vertx-maven-plugin</artifactId>
<version>1.0.13</version>
<executions>
<execution>
<id>vmp</id>
<goals>
<goal>package</goal>
<goal>initialize</goal>
</goals>
</execution>
</executions>
<configuration>
<redeploy>true</redeploy>
</configuration>
</plugin>
</plugins>
</build>
文件结构如下:
src/main/resources/webroot
| index.html
当我击中localhost:8888
它时它确实有效,但localhost:8888/vue/vue.js
没有。还有什么我需要配置的吗?
解决方案
将路由器配置更改为:
router.route().handler(StaticHandler.create("META-INF/resources"))
然后将浏览器指向:
http://localhost:8888/webjars/vue/2.5.16/vue.js
推荐阅读
- r - 绘图仅到达 Y 轴的中间
- google-sheets - Google Sheet Pivot Table 通常比 QUERY 函数慢吗?最佳实践是什么?
- swift - 如何在 macOS 中使用 Swift 或 Objective-C 发送系统键盘事件(带有 maskControl 的上箭头)?
- azure - Azure 无法创建 ARM 模板
- python - Python netmiko 创建文件夹今天日期
- bioinformatics - snakemake 6.0.5:输入文件夹列表和每个文件夹中的多个文件(合并车道)
- java - Java & Gradle & log4j NoClassDefFoundError: org/apache/logging/log4j/LogManager
- javascript - 如何在 vueX 中添加选择下拉过滤器
- python - 如何查找用于特定设备的 ttyUSB
- sql - INSERT 触发器:INSERT 后更新