我只是想用 Vaadin 10 和 Spring boot 做一个学习练习。我还添加了 Sprint Security,因此演示会提示输入用户名和密码。但是,当我正确键入它们时,浏览器只会显示:
Could not navigate to ''
Reason: Couldn't find route for ''
Available routes:
This detailed message is only shown when running in development mode.
我宁愿看到一个带有“点击我”的按钮。
我的 MainView 类是:
@Route
public class MainView extends VerticalLayout {
public MainView() {
add(new Button("Click me", e -> Notification.show("Hello Spring+Vaadin user!")));
}
}
我的 WebSecurityConfigurerAdapter 是:
@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").hasRole("USER").and().formLogin();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication().withUser("test").password("test").roles("USER");
}
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
}
非常感谢任何帮助。非常感谢。
标记。