Webjars не работают в приложении vert.x - PullRequest
0 голосов
/ 29 марта 2019

Как правильно настроить webjars в приложении vert.x? У меня есть это простое приложение:

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 - нет. Есть что-то еще, что мне нужно настроить?

1 Ответ

0 голосов
/ 29 марта 2019

Измените конфигурацию маршрутизатора на:

router.route().handler(StaticHandler.create("META-INF/resources"))

Затем укажите в браузере:

http://localhost:8888/webjars/vue/2.5.16/vue.js
...