No UIProvider has been added and there is no “UI” init parameter Vaadin err

I recived No UIProvider has been added and there is no “UI” init parameter error after I tried dependency injection in Vaadin Framework. I used dedicated Vaadin Spring Addon. I also changed VaadinServlet to SpringVaadinServlet, still doesn’t work.

There is my MainView:

@Theme("mytheme")
@SpringUI
@ComponentScan
@Widgetset("net.elenx.MyAppWidgetset")
public class MainView extends UI {

    @Autowired private VerticalLayout template;

    @Override protected void init(VaadinRequest vaadinRequest) {
        new AnnotationConfigApplicationContext(SpringConfig.class);
        this.setContent(template);
    }

    @WebServlet(urlPatterns = "/*", name = "MyUIServlet", asyncSupported = true)
    @VaadinServletConfiguration(ui = MainView.class, productionMode = false) 
    public static class MyUIServlet extends SpringVaadinServlet {
    }
}

NavigationBar

[code]
@Configuration
@EnableVaadin
public class NavigationBar {

@Bean
HorizontalLayout navigationBar(Button hamburgerButton, Label elenxLogo) {
    System.out.println("Hello from NavigationBar bean!");
    HorizontalLayout navbar = new HorizontalLayout();
    navbar.setWidth("100%");
    navbar.setMargin(true);
    navbar.setHeight(50, Sizeable.Unit.PIXELS);
    navbar.addComponent(hamburgerButton);
    navbar.addComponent(elenxLogo);
    navbar.addStyleName("navigation-bar");
    return navbar;
}

@Bean
Button hamburgerButton() {
    Button hamburgerButton = new Button();
    hamburgerButton.addStyleName("hamburger-button");
    hamburgerButton.setIcon(VaadinIcons.MENU);
    return hamburgerButton;
}

@Bean
Label elenxLogo() {
    Label logo = new Label("ElenX");
    logo.addStyleName("elenx-logo");
    logo.setWidthUndefined();
    logo.setEnabled(false);
    return logo;
}

}
[/code]SpringConfig

[color=#5b7f8b]
@Configuration
[/color]
[color=#5b7f8b]
@EnableVaadin
[/color]
[color=#5b7f8b]
@Import(NavigationBar.class)
[/color]
[color=#5b7f8b]
public class SpringConfig {
[/color]

[color=#5b7f8b]
    @Bean
[/color]
[color=#5b7f8b]
    VerticalLayout template(HorizontalLayout navigationBar) {
[/color]
[color=#5b7f8b]
        System.out.println("Hello from template bean!");
[/color]
[color=#5b7f8b]
        VerticalLayout template = new VerticalLayout();
[/color]
[color=#5b7f8b]
        //NavigationBar navigationBar = new NavigationBar();
[/color]
[color=#5b7f8b]
        Sidebar sidebar = new Sidebar();
[/color]
[color=#5b7f8b]
        template.setMargin(false);
[/color]
[color=#5b7f8b]
        template.setSpacing(false);
[/color]
[color=#5b7f8b]
        template.setHeight("100%");
[/color]
[color=#5b7f8b]
        template.addComponent(navigationBar);
[/color]
[color=#5b7f8b]
        template.addComponent(sidebar.getSidebar());
[/color]
[color=#5b7f8b]
        template.setExpandRatio(sidebar.getSidebar(), 1.0f);
[/color]
[color=#5b7f8b]
        return template;
[/color]
[color=#5b7f8b]
    }
[/color]
[color=#5b7f8b]
}
[/color]

What is wrong with this code? I have no idea what’s going on…