From b286e140b4ce73eafbf6fdc9f508e011c33a7f7d Mon Sep 17 00:00:00 2001 From: amit2103 Date: Sun, 11 Nov 2018 01:07:32 +0530 Subject: [PATCH] [BAEL-10234] - Move spring-rest-... modules to Boot 2 --- spring-rest-angular/pom.xml | 4 ++-- spring-rest-query-language/pom.xml | 10 ++++++---- .../persistence/dao/MyUserRepository.java | 10 +++++----- .../java/org/baeldung/spring/Application.java | 2 +- spring-rest-shell/pom.xml | 4 ++-- spring-rest-simple/pom.xml | 4 ++-- .../java/org/baeldung/config/Application.java | 2 +- .../java/org/baeldung/config/WebConfig.java | 5 ++--- spring-resttemplate/pom.xml | 4 ++-- .../client/TestRestTemplateBasicLiveTest.java | 19 ++++++++++++------- 10 files changed, 35 insertions(+), 29 deletions(-) diff --git a/spring-rest-angular/pom.xml b/spring-rest-angular/pom.xml index 7aedfa486b..5240ae24e7 100644 --- a/spring-rest-angular/pom.xml +++ b/spring-rest-angular/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-rest-query-language/pom.xml b/spring-rest-query-language/pom.xml index 8b24c7b8fb..a06b1a7fc1 100644 --- a/spring-rest-query-language/pom.xml +++ b/spring-rest-query-language/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 @@ -149,6 +149,7 @@ org.javassist javassist + ${javassist.version} mysql @@ -349,11 +350,12 @@ 1.4.9 - + 3.21.0-GA + 19.0 3.5 - + 1.6.1 1.1.3 diff --git a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java b/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java index 82ae1ee841..327d17e25a 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java +++ b/spring-rest-query-language/src/main/java/org/baeldung/persistence/dao/MyUserRepository.java @@ -1,17 +1,17 @@ package org.baeldung.persistence.dao; -import com.querydsl.core.types.dsl.StringExpression; import org.baeldung.persistence.model.MyUser; import org.baeldung.persistence.model.QMyUser; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.querydsl.QueryDslPredicateExecutor; +import org.springframework.data.querydsl.QuerydslPredicateExecutor; import org.springframework.data.querydsl.binding.QuerydslBinderCustomizer; import org.springframework.data.querydsl.binding.QuerydslBindings; - -import com.querydsl.core.types.dsl.StringPath; import org.springframework.data.querydsl.binding.SingleValueBinding; -public interface MyUserRepository extends JpaRepository, QueryDslPredicateExecutor, QuerydslBinderCustomizer { +import com.querydsl.core.types.dsl.StringExpression; +import com.querydsl.core.types.dsl.StringPath; + +public interface MyUserRepository extends JpaRepository, QuerydslPredicateExecutor, QuerydslBinderCustomizer { @Override default public void customize(final QuerydslBindings bindings, final QMyUser root) { bindings.bind(String.class) diff --git a/spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java b/spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java index 7aa9ea5bc3..4a914d947e 100644 --- a/spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java +++ b/spring-rest-query-language/src/main/java/org/baeldung/spring/Application.java @@ -7,7 +7,7 @@ import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.builder.SpringApplicationBuilder; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.web.context.request.RequestContextListener; diff --git a/spring-rest-shell/pom.xml b/spring-rest-shell/pom.xml index 7a604946b6..540b3d08eb 100644 --- a/spring-rest-shell/pom.xml +++ b/spring-rest-shell/pom.xml @@ -8,10 +8,10 @@ A simple project to demonstrate Spring REST Shell features. - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-rest-simple/pom.xml b/spring-rest-simple/pom.xml index d39e3a43c1..f592fef237 100644 --- a/spring-rest-simple/pom.xml +++ b/spring-rest-simple/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-rest-simple/src/main/java/org/baeldung/config/Application.java b/spring-rest-simple/src/main/java/org/baeldung/config/Application.java index 3a98da82c9..5c9a186619 100644 --- a/spring-rest-simple/src/main/java/org/baeldung/config/Application.java +++ b/spring-rest-simple/src/main/java/org/baeldung/config/Application.java @@ -3,7 +3,7 @@ package org.baeldung.config; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.web.support.SpringBootServletInitializer; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; import org.springframework.context.annotation.ComponentScan; @EnableAutoConfiguration diff --git a/spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java index 309a36609a..191b87a8f2 100644 --- a/spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java +++ b/spring-rest-simple/src/main/java/org/baeldung/config/WebConfig.java @@ -14,7 +14,7 @@ import org.springframework.http.converter.xml.MarshallingHttpMessageConverter; import org.springframework.oxm.xstream.XStreamMarshaller; import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer; import org.springframework.web.servlet.config.annotation.EnableWebMvc; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import java.text.SimpleDateFormat; import java.util.List; @@ -25,7 +25,7 @@ import java.util.List; @Configuration @EnableWebMvc @ComponentScan({ "org.baeldung.web" }) -public class WebConfig extends WebMvcConfigurerAdapter { +public class WebConfig implements WebMvcConfigurer { public WebConfig() { super(); @@ -48,7 +48,6 @@ public class WebConfig extends WebMvcConfigurerAdapter { messageConverters.add(new ProtobufHttpMessageConverter()); messageConverters.add(new KryoHttpMessageConverter()); messageConverters.add(new StringHttpMessageConverter()); - super.configureMessageConverters(messageConverters); } private HttpMessageConverter createXmlHttpMessageConverter() { diff --git a/spring-resttemplate/pom.xml b/spring-resttemplate/pom.xml index 481104372a..9a0978f120 100644 --- a/spring-resttemplate/pom.xml +++ b/spring-resttemplate/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-1 + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-1 + ../parent-boot-2 diff --git a/spring-resttemplate/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java b/spring-resttemplate/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java index 012221efb7..03a76aca74 100644 --- a/spring-resttemplate/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java +++ b/spring-resttemplate/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java @@ -1,7 +1,9 @@ package org.baeldung.client; -import okhttp3.Request; -import okhttp3.RequestBody; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertTrue; + import org.junit.Before; import org.junit.Test; import org.springframework.boot.test.web.client.TestRestTemplate; @@ -12,9 +14,8 @@ import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; import org.springframework.web.client.RestTemplate; -import static org.hamcrest.CoreMatchers.equalTo; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertTrue; +import okhttp3.Request; +import okhttp3.RequestBody; public class TestRestTemplateBasicLiveTest { @@ -39,7 +40,9 @@ public class TestRestTemplateBasicLiveTest { @Test public void givenRestTemplateWrapper_whenSendGetForEntity_thenStatusOk() { - TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplate); + RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder(); + restTemplateBuilder.configure(restTemplate); + TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplateBuilder); ResponseEntity response = testRestTemplate.getForEntity(FOO_RESOURCE_URL + "/1", String.class); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK)); } @@ -55,7 +58,9 @@ public class TestRestTemplateBasicLiveTest { @Test public void givenRestTemplateWrapperWithCredentials_whenSendGetForEntity_thenStatusOk() { - TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplate, "user", "passwd"); + RestTemplateBuilder restTemplateBuilder = new RestTemplateBuilder().basicAuthentication("user", "passwd"); + restTemplateBuilder.configure(restTemplate); + TestRestTemplate testRestTemplate = new TestRestTemplate(restTemplateBuilder); ResponseEntity response = testRestTemplate.getForEntity(URL_SECURED_BY_AUTHENTICATION, String.class); assertThat(response.getStatusCode(), equalTo(HttpStatus.OK));