【问题标题】:Helidon serve static contentHelidon 提供静态内容
【发布时间】:2021-10-04 16:52:01
【问题描述】:

我想从我的 Helidon MP 服务器提供静态内容。但我只收到No handler found for path: /static/index.html

我在src/main/resources/META-INF/microprofile-config.properties 中有configured the static resources

server.static.classpath.location=/static

start my server 与:

Server.builder().config(Config.create()).build().start();

我想我必须添加一个 JaxRsApplication?但是我该怎么做呢?

我发现当我使用io.helidon.microprofile.cdi.Main 时它确实有效,但我想手动创建服务器。

【问题讨论】:

    标签: jax-rs helidon


    【解决方案1】:

    这是一个配置问题,您使用的io.helidon.Config.create() 不支持microprofile-config.properties

    如果您使用Server.create().start()microprofile-config.properties 将开箱即用。

    如果你想传递你自己的配置实例,你可以这样做:

    Server.builder().config(ConfigProvider.getConfig()).build().start();
    

    这与Server.create()的效果相同。


    如果您想使用 Helidon 配置 API,您可以将 org.eclipse.microprofile.config.Config 的实例转换为 io.helidon.config.Config,如下所示:

    io.helidon.config.mp.MpConfig.toHelidonConfig(ConfigProvider.getConfig())
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-18
      • 2018-01-29
      • 1970-01-01
      • 2021-11-15
      相关资源
      最近更新 更多