Vaadin + Springboot Image

Where I need to put one image (directory) to use in Image component?


Image accepts type of Resource. Implementations of Resource are:

  • ExternalResource - any http url (not necessarily your case)
  • ThemeResource - put it into your theme directory
  • ClassResource - file in your class path
  • FileResource - this if from Vaadin docs: “A file object that can be accessed as a file resource is defined with the standard class. You can create the file either with an absolute or relative path, but the base path of the relative path depends on the installation of the web server. For example, with Apache Tomcat, the default current directory would be the installation path of Tomcat.”


I using springboot… and I try to put my image on

and when I try to insert in my image component the url dont work

Is it a maven project? If so you can put the image in src/main/resources/ an then use a ClassResource

In resources dir the file at least goes to target/classes and you can use ClassResource(“file.png”). I’m not sure what is path to be used with FileResource

Marco is maven project.

So at the prop SRC from Component image in Vaadin Designer I put ClassResource(“file.pgn”) ?? should work?

Dont work. when I hit enter, the value disappears, and dont show anything

I don’t use Vaadin Designer but, as stated in javadocs, if you create the resource as ClassResource(“file.png”) the resource is relative to the location of the UI class.

So if your UI is in package then the image should be put in src/main/resources/my/app

You can also use ClassResource(MyComponent.class, “file.png”); in this case the resource should be but in same package as MyComponent class (always in src/main/resources)