Vaadin + Spring Boot errors: “Cannot enhance @Configuration” and “More than one Servlet Mapping defined”

只愿长相守 提交于 2019-12-07 01:52:38

问题


I'm new to Spring and Vaadin. I'm trying to go through tutorial for views navigation.

I'd like to enable @Push in future to update views periodically with data fetched from DB.

The project is very, very simple. I use no configuration class nor any XML - only Java annotations.

Could anyone help me to fix the example code? Because I'm getting following warnings and I'm not sure what can be done with it and what will be the result of ignoring them.

First one is:

onClassPostProcessor : Cannot enhance @Configuration bean definition 'com.vaadin.spring.VaadinConfiguration' since its singleton instance has been created too early. The typical cause is a non-static @Bean method with a BeanDefinitionRegistryPostProcessor return type: Consider declaring such methods as 'static'.

And another one is only when I add compile("com.vaadin:vaadin-push") dependancy:

o.a.util.IOUtils : More than one Servlet Mapping defined. WebSocket may not work org.apache.catalina.core.ApplicationServletRegistration

AppMain

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class AppMain {
    public static void main(String[] args) {
        SpringApplication.run(AppMain.class, args);
    }
}

MyUI

import com.vaadin.annotations.Theme;
import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewDisplay;
import com.vaadin.server.VaadinRequest;
import com.vaadin.spring.annotation.SpringUI;
import com.vaadin.spring.annotation.SpringViewDisplay;
import com.vaadin.ui.*;
import com.vaadin.ui.themes.ValoTheme;

@Theme("valo")
@SpringUI(path = "/ui")
@SpringViewDisplay
public class MyUI extends UI implements ViewDisplay {
    private Panel springViewDisplay;

    @Override
    protected void init(VaadinRequest request) {
        final VerticalLayout root = new VerticalLayout();
        root.setSizeFull();
        setContent(root);

        final CssLayout navigationBar = new CssLayout();
        navigationBar.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);

        root.addComponent(navigationBar);

        springViewDisplay = new Panel();
        springViewDisplay.setSizeFull();

        root.addComponent(springViewDisplay);
        root.setExpandRatio(springViewDisplay, 1.0f);
    }

    @Override
    public void showView(View view) {
        springViewDisplay.setContent((Component) view);
    }
}

DefaultView

import com.vaadin.navigator.View;
import com.vaadin.navigator.ViewChangeListener;
import com.vaadin.spring.annotation.SpringView;
import com.vaadin.ui.Label;
import com.vaadin.ui.VerticalLayout;

import javax.annotation.PostConstruct;

@SpringView(name = DefaultView.VIEW_NAME)
public class DefaultView extends VerticalLayout implements View {
    public static final String VIEW_NAME = "";

    @PostConstruct
    void init() {
        addComponent(new Label("This is the default view"));
    }

    @Override
    public void enter(ViewChangeListener.ViewChangeEvent event) {
        // This view is constructed in the init() method()
    }
}

build.gradle

buildscript {
    ext { springBootVersion = '1.5.6.RELEASE' }
    repositories { mavenCentral() }
    dependencies { classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") }
}

apply plugin: 'java'
apply plugin: 'org.springframework.boot'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories { mavenCentral() }

ext { vaadinVersion = '8.1.0' }

dependencies {
    compile('com.vaadin:vaadin-spring-boot-starter')
    compile("com.vaadin:vaadin-push")
    compile("org.springframework.boot:spring-boot-starter-logging")
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

dependencyManagement {
    imports { mavenBom "com.vaadin:vaadin-bom:${vaadinVersion}" }
}

application.properties

server.port=8091

来源:https://stackoverflow.com/questions/46113772/vaadin-spring-boot-errors-cannot-enhance-configuration-and-more-than-one

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!