3

I want some static resources to be served via HTTP by a vaadin14/spring-boot server.

As I understand from this blog post, there is a convention that all resources placed in META-INF/resources(and some other places) will be served as static content (web fragments)

As an example, i place the following file in:

src/main/resources/META-INF/resources/asd.txt

and maven puts it into JAR as expected:

META-INF/resources/asd.txt

When I ask for localhost:8080/asd.txt the results differ, depending on how the app was started:

  • IDE/eclipse: works (Start the Application.main() method)
  • packaged jar: the vaadin router picks up the request and thells me that there is no route available.

How do i tell vaadin/jetty (or whom ever?) to also serve this static repo when packaged?

We are using vaadin 14.7.0 with spring-boot-starter-parent 2.4.5

markus
  • 511
  • 1
  • 4
  • 15

2 Answers2

1

I had this issue but upgrading to Vaadin 23 and Spring boot 2.5.3 solved the issue for me.

Magnus
  • 2,016
  • 24
  • 32
0

It works also in a packaged jar, exactly as you describe. You can test by doing e.g.

npx @vaadin/cli init hello-resources
cd hello-resources
echo "Hello" > src/main/resources/META-INF/resources/asd.txt
mvn

Now http://localhost:8080/asd.txt returns "Hello"

mvn clean package -Pproduction
java -jar target/hello-resources-1.0-SNAPSHOT.jar

Now http://localhost:8080/asd.txt also returns "Hello"

Artur Signell
  • 1,694
  • 9
  • 9