1

I would like to server static content from my Helidon MP server. But I only get No handler found for path: /static/index.html.

I have configured the static resources in src/main/resources/META-INF/microprofile-config.properties:

server.static.classpath.location=/static

And I start my server with:

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

I guess I have to add an JaxRsApplication? But how do I do that?

I figured out it does work when I use the io.helidon.microprofile.cdi.Main but I want to manually create the server.

Itchy
  • 2,263
  • 28
  • 41

2 Answers2

2

This is a config issue, you are using io.helidon.Config.create() which doesn't support microprofile-config.properties.

If you use Server.create().start(), microprofile-config.properties will work out-of-the-box.

If you want to pass your own instance of config, you can do it like this:

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

This has the same effect as Server.create().


If you want to use the Helidon config API, you can convert an instance of org.eclipse.microprofile.config.Config to io.helidon.config.Config like this:

io.helidon.config.mp.MpConfig.toHelidonConfig(ConfigProvider.getConfig())
Romain Grecourt
  • 488
  • 2
  • 4
1

There is a module for serving static content called helidon-webserver-static-content:

https://helidon.io/docs/v2/apidocs/io.helidon.webserver.staticcontent/io/helidon/webserver/staticcontent/StaticContentSupport.html

Here are some examples:

https://www.tabnine.com/code/java/classes/io.helidon.webserver.StaticContentSupport

pref
  • 1,651
  • 14
  • 24