Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 瓦丁春天安全酒店_Java_Spring Security_Vaadin8 - Fatal编程技术网

Java 瓦丁春天安全酒店

Java 瓦丁春天安全酒店,java,spring-security,vaadin8,Java,Spring Security,Vaadin8,我从我发现的一个例子开始工作,下面是Git回购的链接: 它工作得很好,这正是我需要的,除了一件事:我需要服务器推送 以下是我迄今为止所做的工作: 添加了Vaadin推送依赖项 在MainUI.init()方法的开头添加了以下行: 将以下字段添加到MainUI类: Label time = new Label(); Timer timer; private void updateTime() { access(() -> time.setValue(String.format("

我从我发现的一个例子开始工作,下面是Git回购的链接:

它工作得很好,这正是我需要的,除了一件事:我需要服务器推送

以下是我迄今为止所做的工作:

  • 添加了Vaadin推送依赖项
  • 在MainUI.init()方法的开头添加了以下行:

  • 将以下字段添加到MainUI类:

    Label time = new Label();
    Timer timer;
    
    private void updateTime() {
      access(() -> time.setValue(String.format("The server-side time is %s",  LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")))));
    }
    
  • 将以下方法添加到MainUI类:

    Label time = new Label();
    Timer timer;
    
    private void updateTime() {
      access(() -> time.setValue(String.format("The server-side time is %s",  LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")))));
    }
    
  • 最后,在MainUI.init()方法的末尾添加了以下内容:

它主要起作用。我可以看到当前系统时间每秒更新一次。但是当我在浏览器中点击refresh时,应用程序只是挂起了vaadin加载微调器。没有错误消息

我尝试过以下几种选择:

添加方法

public void attach() {
    getPushConfiguration().setTransport(Transport.WEBSOCKET);
    getPushConfiguration().setPushMode(PushMode.AUTOMATIC);
}
并从
init()

这解决了挂起问题,但推送不起作用-没有错误,只是根本不显示时间

我还尝试将
@Push
注释添加到
MainUI
。这将导致与之前相同的行为-刷新时冻结


我怎样才能解决这个问题?欢迎提出任何建议。

尝试以下步骤:

  • @Push
    添加到MainUI.java文件

    @Push(transport=transport.WEBSOCKET,value=PushMode.AUTOMATIC)

  • 而不是:

    getPushConfiguration().setTransport(Transport.WEBSOCKET);
    getPushConfiguration().setPushMode(PushMode.AUTOMATIC)

  • 添加
    @PreDestroy
    以在从mainUI导航时退出计时器

    @PreDestroy
    无效销毁(){
    timer.cancel();
    }

  • 找到完整的修订代码


    我遇到了完全相同的问题,我的解决方案是实现。查看更多信息。

    谢谢您的提示。不幸的是,我看到了同样的行为:(