How to put something into frontend folder with Vaadin12+SptingBoot ?

Hello.

What folder structure should I have in my SpringBoot-2 project to get access to “frontend” folder?

Assume I have a class with annotation

@StyleSheet("mystyles.css")

When I run the app directly from Idea, without any .jar or .war building, I can see empty “mystyles.css” in frontend folder through the browser debugger.
But when I create my own file and put it in one of these folders

  • src/main/frontend
  • src/main/webapp/frontend
  • src/main/resources
  • src/main/resources/frontend
  • src/main/resources/webapp/frontend
  • src/main/resources/VAADIN/frontend
  • etc

my file does not appear as a resource for a browser

What folder should I use?

Hi Sergei.

You should use the url @StyleSheet("frontend://styles/mystyles.css") to point to src/main/resources/META-INF/resources/frontend/styles which is the recommended location for Spring Boot apps that are packaged as jar.

Not sure how you created your project, but our Project Base for Vaadin & Spring from https://vaadin.com/start or from github has a placeholder README with some instructions: https://github.com/vaadin/skeleton-starter-flow-spring/tree/master/src/main/resources/META-INF/resources/frontend/styles

Cheers,
Pekka

And is I use WebSecurityConfigurerAdapter what are the paths that I need to allow access?

I receive this message frm the browser console:

–:1 Access to XMLHttpRequest at ‘http://localhost:8081/frontend/js/flare_partly.json’ from origin ‘http://localhost:8090’ has been blocked by CORS policy: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.