首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不使用vert.x应用程序的Webjars

不使用vert.x应用程序的Webjars
EN

Stack Overflow用户
提问于 2019-03-29 10:31:32
回答 1查看 210关注 0票数 0

在vert.x应用程序中配置webjar的正确方法是什么?我有一个简单的应用程序:

代码语言:javascript
复制
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

代码语言:javascript
复制
<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>

文件结构如下:

代码语言:javascript
复制
src/main/resources/webroot
| index.html

当我点击localhost:8888时,它确实起作用,但localhost:8888/vue/vue.js没有作用。我还有什么需要配置的吗?

EN

回答 1

Stack Overflow用户

发布于 2019-03-29 13:49:58

将路由器配置更改为:

代码语言:javascript
复制
router.route().handler(StaticHandler.create("META-INF/resources"))

然后将浏览器指向:

代码语言:javascript
复制
http://localhost:8888/webjars/vue/2.5.16/vue.js
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55415443

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档