2

In our Muhuru-Bay-Microgrid-Dashboad project we're using code from https://github.com/xpoft/spring-vaadin in an attempt to get Spring Boot and Vaadin to play nicely. The problem - with this approach we can't access many of the other rest service Spring Boot registers at startup such as

/configprops /health /dump /info /trace /mappings /error /autoconfig

Our startup code looks like:

@Bean
public ServletRegistrationBean servletRegistrationBean() {
    final ServletRegistrationBean servletRegistrationBean
            = new ServletRegistrationBean(
            new ru.xpoft.vaadin.SpringVaadinServlet(),
            "/*", "/VAADIN/*");
    return servletRegistrationBean;
}

When we try to access Spring Boot's registered REST services we get redirected to /error - which also doesn't work correctly. Any hints greatly appreciated.

user791437
  • 99
  • 1

2 Answers2

1

Try to use this addon to integrate Spring Boot and Vaadin: https://github.com/peholmst/vaadin4spring It's still in beta, but in my opinion it works much better than the Xpoft addon.

user3551612
  • 206
  • 3
  • 10
1

Using https://github.com/peholmst/vaadin4spring with Spring Boot, I had the same problem of getting HTTP 404 when accessing the application's other REST services. What worked for me was to set VaadinServletConfiguration.SERVLET_URL_MAPPING_PARAMETER_NAME in the spring environment to send the Vaadin UI to a different context path (/ui/*):

@SpringBootApplication
public class AppSpringConfig {
    public static void main(String[] args) {
        new SpringApplicationBuilder(AppSpringConfig.class).initializers(new ApplicationContextInitializer<ConfigurableApplicationContext>() {
            public void initialize(ConfigurableApplicationContext applicationContext)
            {
                ConfigurableEnvironment appEnvironment = applicationContext.getEnvironment();
                Properties props = new Properties();
                props.put(VaadinServletConfiguration.SERVLET_URL_MAPPING_PARAMETER_NAME, "/ui/*");
                PropertySource< ? > source = new PropertiesPropertySource("vaadin", props);
                appEnvironment.getPropertySources().addFirst(source);
            }
        }).run(args);
    }
}
Stefan Reisner
  • 607
  • 5
  • 12