diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml
index 0830381aee..58d974cdba 100644
--- a/spring-rest/pom.xml
+++ b/spring-rest/pom.xml
@@ -8,16 +8,19 @@
war
- parent-boot-5
- com.baeldung
- 0.0.1-SNAPSHOT
- ../parent-boot-5
+ spring-boot-starter-parent
+ org.springframework.boot
+ 2.0.1.RELEASE
+
+ org.springframework.boot
+ spring-boot-starter-web
+
org.springframework.boot
spring-boot-starter-thymeleaf
@@ -32,7 +35,7 @@
org.springframework.boot
- spring-boot-test
+ spring-boot-starter-test
@@ -175,6 +178,12 @@
pact-jvm-provider-junit_2.11
${pact.version}
+
+
+ io.rest-assured
+ rest-assured
+ ${rest-assured.version}
+
@@ -235,7 +244,20 @@
-
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ 3
+ true
+
+ **/*IntegrationTest.java
+ **/*LongRunningUnitTest.java
+ **/*ManualTest.java
+ **/*LiveTest.java
+
+
+
@@ -331,6 +353,7 @@
2.2.0
3.5.11
+ 3.1.0
diff --git a/spring-rest/src/main/java/com/baeldung/custom/CustomApplication.java b/spring-rest/src/main/java/com/baeldung/custom/CustomApplication.java
new file mode 100644
index 0000000000..75f4d714e2
--- /dev/null
+++ b/spring-rest/src/main/java/com/baeldung/custom/CustomApplication.java
@@ -0,0 +1,17 @@
+package com.baeldung.custom;
+
+import java.util.Collections;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class CustomApplication {
+
+ public static void main(String[] args) {
+ SpringApplication app = new SpringApplication(CustomApplication.class);
+ app.setDefaultProperties(Collections.singletonMap("server.port", "8083"));
+ app.run(args);
+ }
+
+}
\ No newline at end of file
diff --git a/spring-rest/src/main/java/com/baeldung/custom/ServerPortCustomizer.java b/spring-rest/src/main/java/com/baeldung/custom/ServerPortCustomizer.java
new file mode 100644
index 0000000000..978e7c8a82
--- /dev/null
+++ b/spring-rest/src/main/java/com/baeldung/custom/ServerPortCustomizer.java
@@ -0,0 +1,15 @@
+package com.baeldung.custom;
+
+import org.springframework.boot.web.server.ConfigurableWebServerFactory;
+import org.springframework.boot.web.server.WebServerFactoryCustomizer;
+import org.springframework.stereotype.Component;
+
+//@Component
+public class ServerPortCustomizer implements WebServerFactoryCustomizer {
+
+ @Override
+ public void customize(ConfigurableWebServerFactory factory) {
+ factory.setPort(8086);
+ }
+
+}
\ No newline at end of file
diff --git a/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java b/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java
index 41042008ef..e9d451b55e 100644
--- a/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java
+++ b/spring-rest/src/main/java/com/baeldung/web/log/app/Application.java
@@ -3,8 +3,8 @@ package com.baeldung.web.log.app;
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.context.annotation.ComponentScan;
+import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@EnableAutoConfiguration
@ComponentScan("com.baeldung.web.log")
diff --git a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java
index 7de88d44a8..b1ddf16dfe 100644
--- a/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java
+++ b/spring-rest/src/main/java/com/baeldung/web/log/controller/TaxiFareController.java
@@ -5,11 +5,9 @@ import javax.validation.Valid;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.ResponseBody;
import com.baeldung.web.log.data.RateCard;
import com.baeldung.web.log.data.TaxiRide;
diff --git a/spring-rest/src/main/java/org/baeldung/config/MainApplication.java b/spring-rest/src/main/java/org/baeldung/config/MainApplication.java
index 36b021a537..6a7fdc041a 100644
--- a/spring-rest/src/main/java/org/baeldung/config/MainApplication.java
+++ b/spring-rest/src/main/java/org/baeldung/config/MainApplication.java
@@ -3,11 +3,11 @@ package org.baeldung.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.annotation.ComponentScan;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableAutoConfiguration
@ComponentScan("org.baeldung")
-public class MainApplication extends WebMvcConfigurerAdapter {
+public class MainApplication implements WebMvcConfigurer {
public static void main(final String[] args) {
SpringApplication.run(MainApplication.class, args);
diff --git a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
index f42c3cb283..5a6f906204 100644
--- a/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
+++ b/spring-rest/src/main/java/org/baeldung/config/WebConfig.java
@@ -3,7 +3,7 @@ package org.baeldung.config;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/*
* Please note that main web configuration is in src/main/webapp/WEB-INF/api-servlet.xml
@@ -11,7 +11,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
@Configuration
@EnableWebMvc
@ComponentScan({ "org.baeldung.web" })
-public class WebConfig extends WebMvcConfigurerAdapter {
+public class WebConfig implements WebMvcConfigurer {
public WebConfig() {
super();
diff --git a/spring-rest/src/main/resources/application.properties b/spring-rest/src/main/resources/application.properties
index 300589f561..dd7e4e2f2d 100644
--- a/spring-rest/src/main/resources/application.properties
+++ b/spring-rest/src/main/resources/application.properties
@@ -1,2 +1,2 @@
server.port= 8082
-server.context-path=/spring-rest
\ No newline at end of file
+server.servlet.context-path=/spring-rest
\ No newline at end of file
diff --git a/spring-rest/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java b/spring-rest/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java
index a26801429e..a8a71c7d73 100644
--- a/spring-rest/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java
+++ b/spring-rest/src/test/java/org/baeldung/client/TestRestTemplateBasicLiveTest.java
@@ -19,14 +19,14 @@ import static org.junit.Assert.assertTrue;
public class TestRestTemplateBasicLiveTest {
- private RestTemplate restTemplate;
+ private RestTemplateBuilder restTemplate;
private static final String FOO_RESOURCE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest/foos";
private static final String URL_SECURED_BY_AUTHENTICATION = "http://httpbin.org/basic-auth/user/passwd";
private static final String BASE_URL = "http://localhost:" + APPLICATION_PORT + "/spring-rest";
@Before
public void beforeTest() {
- restTemplate = new RestTemplate();
+ restTemplate = new RestTemplateBuilder();
}
// GET
diff --git a/spring-rest/src/test/java/org/baeldung/pact/PactProviderTest.java b/spring-rest/src/test/java/org/baeldung/pact/PactProviderLiveTest.java
similarity index 97%
rename from spring-rest/src/test/java/org/baeldung/pact/PactProviderTest.java
rename to spring-rest/src/test/java/org/baeldung/pact/PactProviderLiveTest.java
index 0456b0d3e7..f020fb88db 100644
--- a/spring-rest/src/test/java/org/baeldung/pact/PactProviderTest.java
+++ b/spring-rest/src/test/java/org/baeldung/pact/PactProviderLiveTest.java
@@ -17,7 +17,7 @@ import au.com.dius.pact.provider.junit.target.TestTarget;
@RunWith(PactRunner.class)
@Provider("test_provider")
@PactFolder("pacts")
-public class PactProviderTest {
+public class PactProviderLiveTest {
@TestTarget
public final Target target = new HttpTarget("http", "localhost", 8082, "/spring-rest");
diff --git a/spring-rest/src/test/resources/cache/2d9345a30d2cc31bb3091d70a8ef6c18.0 b/spring-rest/src/test/resources/cache/2d9345a30d2cc31bb3091d70a8ef6c18.0
index f0a4a9d3fd..bc64f40e5d 100644
--- a/spring-rest/src/test/resources/cache/2d9345a30d2cc31bb3091d70a8ef6c18.0
+++ b/spring-rest/src/test/resources/cache/2d9345a30d2cc31bb3091d70a8ef6c18.0
@@ -8,7 +8,7 @@ Content-Length: 1759
Connection: keep-alive
Accept-Ranges: bytes
Server: nginx/1.10.0 (Ubuntu)
-Date: Fri, 23 Jun 2017 15:44:52 GMT
+Date: Sat, 28 Apr 2018 20:53:35 GMT
Last-Modified: Tue, 27 May 2014 02:35:47 GMT
ETag: "5383fa03-6df"
OkHttp-Sent-Millis: 1489054646765
diff --git a/spring-rest/src/test/resources/cache/4b217e04ba52215f3a6b64d28f6729c6.0 b/spring-rest/src/test/resources/cache/4b217e04ba52215f3a6b64d28f6729c6.0
index c202030c3f..bbd34c75f6 100644
--- a/spring-rest/src/test/resources/cache/4b217e04ba52215f3a6b64d28f6729c6.0
+++ b/spring-rest/src/test/resources/cache/4b217e04ba52215f3a6b64d28f6729c6.0
@@ -4,10 +4,10 @@ GET
HTTP/1.1 301 Moved Permanently
8
Server: nginx/1.10.0 (Ubuntu)
-Date: Sat, 24 Jun 2017 01:06:43 GMT
+Date: Sat, 28 Apr 2018 20:53:33 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: https://publicobject.com/helloworld.txt
-OkHttp-Sent-Millis: 1498266403462
-OkHttp-Received-Millis: 1498266403727
+OkHttp-Sent-Millis: 1524948815122
+OkHttp-Received-Millis: 1524948815342
diff --git a/spring-rest/src/test/resources/cache/journal b/spring-rest/src/test/resources/cache/journal
index 4640ee324c..eed030a85d 100644
--- a/spring-rest/src/test/resources/cache/journal
+++ b/spring-rest/src/test/resources/cache/journal
@@ -61,3 +61,9 @@ READ 2d9345a30d2cc31bb3091d70a8ef6c18
READ 4b217e04ba52215f3a6b64d28f6729c6
DIRTY 4b217e04ba52215f3a6b64d28f6729c6
CLEAN 4b217e04ba52215f3a6b64d28f6729c6 333 194
+READ 4b217e04ba52215f3a6b64d28f6729c6
+DIRTY 4b217e04ba52215f3a6b64d28f6729c6
+CLEAN 4b217e04ba52215f3a6b64d28f6729c6 333 194
+READ 2d9345a30d2cc31bb3091d70a8ef6c18
+DIRTY 2d9345a30d2cc31bb3091d70a8ef6c18
+CLEAN 2d9345a30d2cc31bb3091d70a8ef6c18 7618 1759