diff --git a/spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java b/spring-security-basic-auth/src/main/java/org/baeldung/spring/MvcConfig.java similarity index 92% rename from spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java rename to spring-security-basic-auth/src/main/java/org/baeldung/spring/MvcConfig.java index b353405fc1..74c11478ee 100644 --- a/spring-security-basic-auth/src/main/java/org/baeldung/spring/FrontendConfig.java +++ b/spring-security-basic-auth/src/main/java/org/baeldung/spring/MvcConfig.java @@ -9,11 +9,11 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter import org.springframework.web.servlet.view.InternalResourceViewResolver; import org.springframework.web.servlet.view.JstlView; -@EnableWebMvc @Configuration -public class FrontendConfig extends WebMvcConfigurerAdapter { +@EnableWebMvc +public class MvcConfig extends WebMvcConfigurerAdapter { - public FrontendConfig() { + public MvcConfig() { super(); } diff --git a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml index d4ef6ebb8b..461f32bde5 100644 --- a/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-basic-auth/src/main/webapp/WEB-INF/web.xml @@ -6,7 +6,7 @@ http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring Security Basic Auth Application diff --git a/spring-security-custom/pom.xml b/spring-security-custom/pom.xml index 4477b0b41c..dba76c6a14 100644 --- a/spring-security-custom/pom.xml +++ b/spring-security-custom/pom.xml @@ -1,142 +1,157 @@ - - 4.0.0 - org.baeldung - spring-security-custom - 0.1-SNAPSHOT + + 4.0.0 + org.baeldung + spring-security-custom + 0.1-SNAPSHOT - spring-security-custom - war + spring-security-custom + war - + - + - - org.springframework.security - spring-security-web - ${org.springframework.security.version} - - - org.springframework.security - spring-security-config - ${org.springframework.security.version} - + + org.springframework.security + spring-security-web + ${org.springframework.security.version} + + + org.springframework.security + spring-security-config + ${org.springframework.security.version} + - + - - org.springframework - spring-core - ${org.springframework.version} - - - org.springframework - spring-context - ${org.springframework.version} - - - org.springframework - spring-jdbc - ${org.springframework.version} - - - org.springframework - spring-beans - ${org.springframework.version} - - - org.springframework - spring-aop - ${org.springframework.version} - - - org.springframework - spring-tx - ${org.springframework.version} - - - org.springframework - spring-expression - ${org.springframework.version} - + + org.springframework + spring-core + ${org.springframework.version} + + + org.springframework + spring-context + ${org.springframework.version} + + + org.springframework + spring-jdbc + ${org.springframework.version} + + + org.springframework + spring-beans + ${org.springframework.version} + + + org.springframework + spring-aop + ${org.springframework.version} + + + org.springframework + spring-tx + ${org.springframework.version} + + + org.springframework + spring-expression + ${org.springframework.version} + - - org.springframework - spring-web - ${org.springframework.version} - - - org.springframework - spring-webmvc - ${org.springframework.version} - + + org.springframework + spring-web + ${org.springframework.version} + + + org.springframework + spring-webmvc + ${org.springframework.version} + + + + org.springframework + spring-oxm + ${org.springframework.version} + - + - - javax.servlet - javax.servlet-api - 3.0.1 - provided - + + com.fasterxml.jackson.core + jackson-databind + 2.2.2 + - - javax.servlet - jstl - 1.2 - runtime - + - + + javax.servlet + javax.servlet-api + 3.0.1 + provided + - - com.google.guava - guava - ${guava.version} - + + javax.servlet + jstl + 1.2 + runtime + - + - - junit - junit-dep - ${junit.version} - test - + + com.google.guava + guava + ${guava.version} + - - org.hamcrest - hamcrest-core - ${org.hamcrest.version} - test - - - org.hamcrest - hamcrest-library - ${org.hamcrest.version} - test - + - - org.mockito - mockito-core - ${mockito.version} - test - + + junit + junit-dep + ${junit.version} + test + - + + org.hamcrest + hamcrest-core + ${org.hamcrest.version} + test + + + org.hamcrest + hamcrest-library + ${org.hamcrest.version} + test + - - spring-security-custom - - - src/main/resources - true - - + + org.mockito + mockito-core + ${mockito.version} + test + + + + + + spring-security-custom + + + src/main/resources + true + + + + - - org.apache.maven.plugins maven-compiler-plugin @@ -148,80 +163,80 @@ source - - - org.apache.maven.plugins - maven-surefire-plugin - ${maven-surefire-plugin.version} - - - - - - - - - - - org.codehaus.cargo - cargo-maven2-plugin - ${cargo-maven2-plugin.version} - - true - - jetty8x - embedded - - - - - - - 8082 - - - - + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + + + + + + + - + + org.codehaus.cargo + cargo-maven2-plugin + ${cargo-maven2-plugin.version} + + true + + jetty8x + embedded + + + + + + + 8082 + + + + - + - - - 3.2.3.RELEASE - 3.1.4.RELEASE + - - 4.2.2.Final - 5.1.25 + + + 3.2.3.RELEASE + 3.1.4.RELEASE - - 1.7.5 - 1.0.11 + + 4.2.2.Final + 5.1.25 - - 5.0.1.Final + + 1.7.5 + 1.0.11 - - 14.0.1 - 3.1 + + 5.0.1.Final - - 1.3 - 4.11 - 1.9.5 + + 14.0.1 + 3.1 - 4.2.4 - 4.2.5 + + 1.3 + 4.11 + 1.9.5 - 1.8.0 - 1.8.9 + 4.2.4 + 4.2.5 - - 1.4.2 - 2.14.1 - + 1.8.0 + 1.8.9 + + + 1.4.2 + 2.14.1 + \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java b/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java index fa6f5f6d56..8c3d677af6 100644 --- a/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java +++ b/spring-security-custom/src/main/java/org/baeldung/spring/WebConfig.java @@ -1,10 +1,16 @@ package org.baeldung.spring; +import java.util.List; + import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @Configuration +@EnableWebMvc @ComponentScan("org.baeldung.web") public class WebConfig extends WebMvcConfigurerAdapter { @@ -12,6 +18,14 @@ public class WebConfig extends WebMvcConfigurerAdapter { super(); } - // API + // beans + + @Override + public void configureMessageConverters(final List> converters) { + super.configureMessageConverters(converters); + converters.add(new MappingJackson2HttpMessageConverter()); + } + + // } \ No newline at end of file diff --git a/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java b/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java index 352045989d..09c1dac933 100644 --- a/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java +++ b/spring-security-custom/src/main/java/org/baeldung/web/dto/Foo.java @@ -2,6 +2,9 @@ package org.baeldung.web.dto; import java.io.Serializable; +import javax.xml.bind.annotation.XmlRootElement; + +@XmlRootElement public class Foo implements Serializable { public Foo() { diff --git a/spring-security-custom/src/main/webapp/WEB-INF/web.xml b/spring-security-custom/src/main/webapp/WEB-INF/web.xml index fe62026bc7..db64386b14 100644 --- a/spring-security-custom/src/main/webapp/WEB-INF/web.xml +++ b/spring-security-custom/src/main/webapp/WEB-INF/web.xml @@ -1,50 +1,52 @@ - + http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" + id="WebApp_ID" version="3.0"> - Spring MVC Application + Spring Security Custom Application - - - contextClass - + + + contextClass + org.springframework.web.context.support.AnnotationConfigWebApplicationContext - - - contextConfigLocation - org.baeldung.spring - + + + contextConfigLocation + org.baeldung.spring + - - org.springframework.web.context.ContextLoaderListener - + + org.springframework.web.context.ContextLoaderListener + - - - api - org.springframework.web.servlet.DispatcherServlet - 1 - - - api - /api/* - + + + api + org.springframework.web.servlet.DispatcherServlet + 1 + + + api + /api/* + - - - springSecurityFilterChain - org.springframework.web.filter.DelegatingFilterProxy - - - springSecurityFilterChain - /* - + + + springSecurityFilterChain + org.springframework.web.filter.DelegatingFilterProxy + + + springSecurityFilterChain + /* + - - - + + index.html + \ No newline at end of file