diff --git a/samples/websocket/src/main/java/sample/config/H2Initializer.java b/samples/websocket/src/main/java/sample/config/H2Initializer.java deleted file mode 100644 index b55e679c..00000000 --- a/samples/websocket/src/main/java/sample/config/H2Initializer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2014-2016 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package sample.config; - -import org.h2.server.web.WebServlet; - -import org.springframework.boot.context.embedded.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Initializes the H2 {@link WebServlet} so we can access our in memory database from the - * URL "/h2". - * - * @author Rob Winch - */ -@Configuration -public class H2Initializer { - - @Bean - public ServletRegistrationBean h2Servlet() { - ServletRegistrationBean servletBean = new ServletRegistrationBean(); - servletBean.addUrlMappings("/h2/*"); - servletBean.setServlet(new WebServlet()); - return servletBean; - } -} diff --git a/samples/websocket/src/main/java/sample/config/WebSecurityConfig.java b/samples/websocket/src/main/java/sample/config/WebSecurityConfig.java index 757488fc..6579ca4b 100644 --- a/samples/websocket/src/main/java/sample/config/WebSecurityConfig.java +++ b/samples/websocket/src/main/java/sample/config/WebSecurityConfig.java @@ -22,6 +22,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.builders.WebSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; import org.springframework.security.core.userdetails.UserDetailsService; @@ -51,6 +52,14 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { } // @formatter:on + // @formatter:off + @Override + public void configure(WebSecurity web) throws Exception { + web + .ignoring().antMatchers("/h2-console/**"); + } + // @formatter:on + // @formatter:off @Autowired public void configureGlobal(AuthenticationManagerBuilder auth, UserDetailsService userDetailsService) throws Exception { diff --git a/samples/websocket/src/main/resources/application.properties b/samples/websocket/src/main/resources/application.properties index f0baad36..16b8068d 100644 --- a/samples/websocket/src/main/resources/application.properties +++ b/samples/websocket/src/main/resources/application.properties @@ -1,2 +1,3 @@ spring.thymeleaf.cache=false spring.template.cache=false +spring.h2.console.enabled=true diff --git a/samples/websocket/src/main/resources/templates/layout.html b/samples/websocket/src/main/resources/templates/layout.html index f1b15e4b..6174fc17 100644 --- a/samples/websocket/src/main/resources/templates/layout.html +++ b/samples/websocket/src/main/resources/templates/layout.html @@ -93,7 +93,7 @@ @@ -121,4 +121,4 @@ - \ No newline at end of file +