Spring boot Vaadin@Push带Vaadin4弹簧安全装置
是否有人将Vaadin@Push与Vaadin弹簧靴启动器和Vaadin4Spring安全扩展一起使用 以下是与我们项目相关的Vaadin依赖项:Spring boot Vaadin@Push带Vaadin4弹簧安全装置,spring-boot,vaadin,vaadin4spring,vaadin-push,vaadin-spring-boot,Spring Boot,Vaadin,Vaadin4spring,Vaadin Push,Vaadin Spring Boot,是否有人将Vaadin@Push与Vaadin弹簧靴启动器和Vaadin4Spring安全扩展一起使用 以下是与我们项目相关的Vaadin依赖项: compile 'com.vaadin:vaadin-client-compiled:7.5.8' compile 'com.vaadin:vaadin-client:7.5.8' compile 'com.vaadin:vaadin-themes:7.5.8' compile 'com.vaadin:vaadin-server:7.
compile 'com.vaadin:vaadin-client-compiled:7.5.8'
compile 'com.vaadin:vaadin-client:7.5.8'
compile 'com.vaadin:vaadin-themes:7.5.8'
compile 'com.vaadin:vaadin-server:7.5.8'
compile 'com.vaadin:vaadin-push:7.5.8'
// Official VaadinSpring Integration
compile("com.vaadin:vaadin-spring-boot-starter:1.0.0")
//Vaadin extentions - in the future more of those will go to official VaadinSpring Integration
compile("org.vaadin.spring.extensions:vaadin-spring-ext-security:0.0.6.RELEASE")
compile("org.vaadin.spring.extensions:vaadin-spring-ext-core:0.0.6.RELEASE")
compile("org.vaadin.spring.extensions:vaadin-spring-ext-boot:0.0.6.RELEASE")
compile("org.vaadin.spring.extensions:vaadin-spring-ext-test:0.0.6.RELEASE")
下面是UI类的注释
@Theme("mytheme")
@Title(com.test.util.Constants.TITLE)
@EnableOAuth2Client
@SpringUI
@Push
public class MyVaadinUI extends UI {
...
}
和Application.java
@EnableVaadinExtensions
@SpringBootApplication
@EnableConfigurationProperties
@EnableI18N
@EnableEventBus
@RestController
@EnableOAuth2Client
public class Application extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(Application.class);
}
@Bean
public RequestContextListener requestContextListener(){
return new RequestContextListener();
}
@Bean
public FilterRegistrationBean hiddenHttpMethodFilter() {
HiddenHttpMethodFilter hiddenHttpMethodFilter = new HiddenHttpMethodFilter();
FilterRegistrationBean registrationBean = new FilterRegistrationBean();
registrationBean.setFilter(hiddenHttpMethodFilter);
return registrationBean;
}
@Bean(name = "messageSource")
public ResourceBundleMessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("messages/messages");
logger.debug("Returning messageSource: " + ((messageSource != null) ? messageSource.toString() : "NULL"));
return messageSource;
}
}
我们一打电话
security.login(username.getValue(),password.getValue());
(安全性是org.vaadin.spring.security.VaadinSecurity;)
我们得到以下例外情况
16:36:35.272[http-nio-8080-exec-9]错误c.b.g.c.s.v.views.login.LoginBox/login登录过程中出现登录错误login.org.springframework.beans.factory.BeanCreationException:创建名为“scopedTarget.httpService”的bean时出错:当前线程的作用域“请求”未激活;如果您想从一个单体引用它,请考虑为这个bean定义一个作用域代理;嵌套异常为java.lang.IllegalStateException:未找到线程绑定请求:您是在实际web请求之外引用请求属性,还是在原始接收线程之外处理请求?如果您实际上在web请求中操作,并且仍然收到此消息,那么您的代码可能在DispatcherServlet/DispatcherPortlet之外运行:在这种情况下,请使用RequestContextListener或RequestContextFilter公开当前请求
非常感谢您提供的帮助。您使用的是WebSocket,它不使用servlet请求,也不会自动激活“请求”范围
如果您使用@Push(transport=WEBSOCKET\u XHR),它应该可以工作,因为websockets通道将仅用于服务器->客户端推送,标准HTTP请求将用于客户端->服务器消息。您使用的是websockets,它不使用servlet请求,也不会自动激活“请求”范围
如果您使用@Push(transport=WEBSOCKET\u XHR),它应该可以工作,因为websockets通道将仅用于服务器->客户端推送,标准HTTP请求将用于客户端->服务器消息。感谢您的回复。该解决方案适用于Vaadin 7.6.1,但目前我们使用的是7.5.8版。我们无法升级,因为其中一个插件与7.6有问题。似乎WEBSOCKET_XHR在7.5.8上不可用。您是否有针对Vaadin 7.5.8的可能解决方案?再次感谢您的帮助。LONG_轮询也是基于HTTP的,因此在7.5中也可以使用。对于websockets和7.5,您可能需要自己在重写的VaadinService.RequestStart中初始化Spring上下文谢谢您的回复。该解决方案适用于Vaadin 7.6.1,但目前我们使用的是7.5.8版。我们无法升级,因为其中一个插件与7.6有问题。似乎WEBSOCKET_XHR在7.5.8上不可用。您是否有针对Vaadin 7.5.8的可能解决方案?再次感谢您的帮助。LONG_轮询也是基于HTTP的,因此在7.5中也可以使用。对于WebSocket和7.5,您可能需要自己在重写的VaadinService.requestStart中初始化Spring上下文