意外的Vaadin会话过期和并行Spring Boot应用程序 [英] Unexpected Vaadin Session Expired and parallel spring boot applications

查看:31
本文介绍了意外的Vaadin会话过期和并行Spring Boot应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Vaadin 8.9.4和Spring boot 2.2.4.RELEASE。我有两个Spring引导应用程序,FirstApplication(server.port=8083)和Second Application(server.port=8084)。这两个应用程序都有@SpringUI扩展UI类的注释类,如下所示。只要我单击Second Application中的按钮,FirstApplication的会话就会过期,反之亦然。只有当我并行使用两个合唱选项卡时才会出现这种情况。如果我使用两个不同的浏览器,一切都按预期工作。

这是不是某种bug,因为我认为这两个应用程序的会话之间没有关系,只是因为它们在不同的端口上独立运行。

注意:我是Spring Boot新手,正在尝试构建2个通过睡觉接口相互通信的微服务。

@SpringUI
@Theme("valo")
public class FirstApplicationUI extends UI {

    private static final long serialVersionUID = 9197592298697220144L;

    @Override
    protected void init(final VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        final Label label = new Label("First Application");
        final Button button = new Button("click");

        button.addClickListener(e -> Notification.show("First Application"));

        layout.addComponents(label, button);

        setContent(layout);
    }
}

@SpringUI
@Theme("valo")
public class SecondApplicationUI extends UI {

    private static final long serialVersionUID = 9059755286859361908L;

    @Override
    protected void init(final VaadinRequest request) {
        final VerticalLayout layout = new VerticalLayout();
        final Label label = new Label("Second Application");
        final Button button = new Button("click");

        button.addClickListener(e -> Notification.show("Second Application"));

        layout.addComponents(label, button);

        setContent(layout);
    }
}

推荐答案

这是您的两个应用程序争夺相同的Cookie;两者都使用相同的名称,并且您的浏览器愉快地向两个后端发送相同的Cookie,因为不考虑端口。

至少在一个应用程序中更改名称;请参阅https://docs.spring.io/spring-boot/docs/current/reference/html/appendix-application-properties.html中的server.servlet.session.cookie.name

这篇关于意外的Vaadin会话过期和并行Spring Boot应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆