0

I am testing out a vaadin 10 application using spring boot. I used https://start.spring.io/ to generate a project. I followed the documentation of vaadin https://vaadin.com/docs/v10/flow/importing-dependencies/tutorial-include-css.html. There the following is stated: "You can place style sheets and other static resources in any folder inside your WAR file except for /VAADIN which is reserved for framework internal use. VaadinServlet handles static resource requests if you have mapped it to / . Otherwise, the servlet container will take care of static resource requests."

I created a stylesheet style.css and placed it under resources folder in my spring boot application. I referenced the stylesheet on my class using @StyleSheet("style.css"). I the classname of div has also been set. But when i run the application it seems my stylesheet is not being used. What is the proper way of placing a stylesheet?

@StyleSheet("style.css")
public class MainView extends VerticalLayout {
    private TextField filter;
    private Button addNewBtn;

    public MainView() {
        TestDiv testDiv = new TestDiv();

        add(testDiv);
    }

    public class TestDiv extends Div {

        public TestDiv() {
            setText("TestDiv");
            setClassName("custom-cell");
        }

    }
}
yusufnazir
  • 131
  • 2
  • 9
  • Can you specify the correct folder you placed your stylesheet in. Is it `src/main/resources`? – rieckpil Sep 28 '18 at 04:55
  • I had also posted on vaadin forums: https://vaadin.com/forum/thread/17298373/17298523. I got the solutions there. Folder structure that works for me: src/main/resources/frontend/ – yusufnazir Sep 28 '18 at 12:33

1 Answers1

3

if you are packaging as a WAR, src/main/resources/static/frontend/,

if JAR: src/main/resources/META-INF/resources/frontend/