1

我只是想用 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();
     }
}

非常感谢任何帮助。非常感谢。

标记。

4

1 回答 1

2

感谢我收到的帮助。我发现了一个简单的错误,我将 MainView 类放在一个子包(称为 gui)中。当我将它移动到与主应用程序类相同的包时,它就可以正常工作了。道歉和感激的感谢。

于 2018-09-25T10:50:43.763 回答