diff --git a/spring-mvc-forms-thymeleaf/pom.xml b/spring-mvc-forms-thymeleaf/pom.xml index 67a2696c8a..504ad1dcb2 100644 --- a/spring-mvc-forms-thymeleaf/pom.xml +++ b/spring-mvc-forms-thymeleaf/pom.xml @@ -9,10 +9,10 @@ spring forms examples using thymeleaf - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest-angular/pom.xml b/spring-rest-angular/pom.xml index 22ddabb4ea..5240ae24e7 100644 --- a/spring-rest-angular/pom.xml +++ b/spring-rest-angular/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java b/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java index d6fe719311..fd10643c53 100644 --- a/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java +++ b/spring-rest-angular/src/main/java/org/baeldung/web/main/Application.java @@ -6,12 +6,12 @@ import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Import; import org.springframework.web.filter.ShallowEtagHeaderFilter; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @SpringBootApplication @EnableAutoConfiguration @Import(PersistenceConfig.class) -public class Application extends WebMvcConfigurerAdapter { +public class Application implements WebMvcConfigurer { public static void main(String[] args) { SpringApplication.run(Application.class, args); diff --git a/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java b/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java index 4d65c02fff..1473d44b92 100644 --- a/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java +++ b/spring-rest-angular/src/test/java/org/baeldung/web/service/StudentServiceIntegrationTest.java @@ -1,62 +1,66 @@ package org.baeldung.web.service; +import static io.restassured.RestAssured.given; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsCollectionContaining.hasItems; +import static org.hamcrest.core.IsEqual.equalTo; + import org.apache.commons.lang3.RandomStringUtils; import org.baeldung.web.main.Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.junit4.SpringRunner; -import static io.restassured.RestAssured.given; -import static org.hamcrest.core.Is.is; -import static org.hamcrest.core.IsCollectionContaining.hasItems; -import static org.hamcrest.core.IsEqual.equalTo; - @RunWith(SpringRunner.class) -@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.DEFINED_PORT) +@SpringBootTest(classes = Application.class, webEnvironment = WebEnvironment.RANDOM_PORT) public class StudentServiceIntegrationTest { + + @LocalServerPort + int port; - private static final String ENDPOINT = "http://localhost:8080/student/get"; + private static final String ENDPOINT = "http://localhost:%s/student/get"; @Test public void givenRequestForStudents_whenPageIsOne_expectContainsNames() { - given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat() + given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat() .body("content.name", hasItems("Bryan", "Ben")); } @Test public void givenRequestForStudents_whenSizeIsTwo_expectTwoItems() { - given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("size", equalTo(2)); + given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("size", equalTo(2)); } @Test public void givenRequestForStudents_whenSizeIsTwo_expectNumberOfElementsTwo() { - given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("numberOfElements", equalTo(2)); + given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("numberOfElements", equalTo(2)); } @Test public void givenRequestForStudents_whenResourcesAreRetrievedPaged_thenExpect200() { - given().params("page", "0", "size", "2").get(ENDPOINT).then().statusCode(200); + given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(200); } @Test public void givenRequestForStudents_whenPageOfResourcesAreRetrievedOutOfBounds_thenExpect500() { - given().params("page", "1000", "size", "2").get(ENDPOINT).then().statusCode(500); + given().params("page", "1000", "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(500); } @Test public void givenRequestForStudents_whenPageNotValid_thenExpect500() { - given().params("page", RandomStringUtils.randomNumeric(5), "size", "2").get(ENDPOINT).then().statusCode(500); + given().params("page", RandomStringUtils.randomNumeric(5), "size", "2").get(String.format(ENDPOINT, port)).then().statusCode(500); } @Test public void givenRequestForStudents_whenPageSizeIsFive_expectFiveItems() { - given().params("page", "0", "size", "5").get(ENDPOINT).then().body("content.size()", is(5)); + given().params("page", "0", "size", "5").get(String.format(ENDPOINT, port)).then().body("content.size()", is(5)); } @Test public void givenResourcesExist_whenFirstPageIsRetrieved_thenPageContainsResources() { - given().params("page", "0", "size", "2").get(ENDPOINT).then().assertThat().body("first", equalTo(true)); + given().params("page", "0", "size", "2").get(String.format(ENDPOINT, port)).then().assertThat().body("first", equalTo(true)); } } diff --git a/spring-rest-query-language/pom.xml b/spring-rest-query-language/pom.xml index 6f790f1f48..70fea91f31 100644 --- a/spring-rest-query-language/pom.xml +++ b/spring-rest-query-language/pom.xml @@ -7,10 +7,10 @@ war - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest-shell/pom.xml b/spring-rest-shell/pom.xml index 8b7ce1770d..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-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest-simple/pom.xml b/spring-rest-simple/pom.xml index e5de463999..d301957eb9 100644 --- a/spring-rest-simple/pom.xml +++ b/spring-rest-simple/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest-template/pom.xml b/spring-rest-template/pom.xml index d86e208987..fa93308cf5 100644 --- a/spring-rest-template/pom.xml +++ b/spring-rest-template/pom.xml @@ -8,10 +8,10 @@ jar - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest/pom.xml b/spring-rest/pom.xml index ea4cfc26d7..5c88697cef 100644 --- a/spring-rest/pom.xml +++ b/spring-rest/pom.xml @@ -7,10 +7,10 @@ war - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-rest/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java b/spring-rest/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java index d811045733..191719b084 100644 --- a/spring-rest/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java +++ b/spring-rest/src/main/java/com/baeldung/resttemplate/lists/client/EmployeeClient.java @@ -43,7 +43,7 @@ public class EmployeeClient ResponseEntity> response = restTemplate.exchange( - "http://localhost:8080/spring-rest/employees/", + "http://localhost:8082/spring-rest/employees/", HttpMethod.GET, null, new ParameterizedTypeReference>(){}); @@ -61,7 +61,7 @@ public class EmployeeClient EmployeeList response = restTemplate.getForObject( - "http://localhost:8080/spring-rest/employees/v2", + "http://localhost:8082/spring-rest/employees/v2", EmployeeList.class); List employees = response.getEmployees(); @@ -80,7 +80,7 @@ public class EmployeeClient newEmployees.add(new Employee(4, "CEO")); restTemplate.postForObject( - "http://localhost:8080/spring-rest/employees/", + "http://localhost:8082/spring-rest/employees/", newEmployees, ResponseEntity.class); } @@ -94,7 +94,7 @@ public class EmployeeClient newEmployees.add(new Employee(4, "CEO")); restTemplate.postForObject( - "http://localhost:8080/spring-rest/employees/v2/", + "http://localhost:8082/spring-rest/employees/v2/", new EmployeeList(newEmployees), ResponseEntity.class); } diff --git a/spring-rest/src/main/java/com/baeldung/sampleapp/web/controller/advice/JsonpControllerAdvice.java b/spring-rest/src/main/java/com/baeldung/sampleapp/web/controller/advice/JsonpControllerAdvice.java deleted file mode 100644 index 853e417d46..0000000000 --- a/spring-rest/src/main/java/com/baeldung/sampleapp/web/controller/advice/JsonpControllerAdvice.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.sampleapp.web.controller.advice; - -import org.springframework.web.bind.annotation.ControllerAdvice; -import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice; - -@ControllerAdvice -public class JsonpControllerAdvice extends AbstractJsonpResponseBodyAdvice { - - public JsonpControllerAdvice() { - super("callback"); - } - -} diff --git a/spring-rest/src/main/java/com/baeldung/web/upload/app/Application.java b/spring-rest/src/main/java/com/baeldung/web/upload/app/UploadApplication.java similarity index 79% rename from spring-rest/src/main/java/com/baeldung/web/upload/app/Application.java rename to spring-rest/src/main/java/com/baeldung/web/upload/app/UploadApplication.java index d6821196eb..f3b1c0dc6f 100644 --- a/spring-rest/src/main/java/com/baeldung/web/upload/app/Application.java +++ b/spring-rest/src/main/java/com/baeldung/web/upload/app/UploadApplication.java @@ -9,9 +9,9 @@ import org.springframework.context.annotation.ComponentScan; @EnableAutoConfiguration @ComponentScan("com.baeldung.web.upload") @SpringBootApplication -public class Application extends SpringBootServletInitializer { +public class UploadApplication extends SpringBootServletInitializer { public static void main(final String[] args) { - SpringApplication.run(Application.class, args); + SpringApplication.run(UploadApplication.class, args); } } \ No newline at end of file diff --git a/spring-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java b/spring-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java index e659897303..f04106c1e1 100644 --- a/spring-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java +++ b/spring-rest/src/test/java/com/baeldung/SpringContextIntegrationTest.java @@ -14,7 +14,7 @@ import com.baeldung.web.log.app.Application; @RunWith(SpringRunner.class) @SpringBootTest(classes = { CustomApplication.class, ImageApplication.class, PropertyEditorApplication.class, - ResponseHeadersApplication.class, Application.class, com.baeldung.web.upload.app.Application.class, + ResponseHeadersApplication.class, Application.class, com.baeldung.web.upload.app.UploadApplication.class, MainApplication.class}) public class SpringContextIntegrationTest { diff --git a/spring-resttemplate/pom.xml b/spring-resttemplate/pom.xml index 2c404a7e8c..9a0978f120 100644 --- a/spring-resttemplate/pom.xml +++ b/spring-resttemplate/pom.xml @@ -8,10 +8,10 @@ war - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-security-mvc-boot/pom.xml b/spring-security-mvc-boot/pom.xml index c072bf0f99..0a40b0b324 100644 --- a/spring-security-mvc-boot/pom.xml +++ b/spring-security-mvc-boot/pom.xml @@ -11,10 +11,10 @@ Spring Security MVC Boot - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 @@ -36,7 +36,7 @@ org.thymeleaf.extras - thymeleaf-extras-springsecurity4 + thymeleaf-extras-springsecurity5 org.springframework.boot diff --git a/spring-security-mvc-boot/src/main/resources/templates/private.html b/spring-security-mvc-boot/src/main/resources/templates/private.html index 5af8c7a13e..035d84bbbd 100644 --- a/spring-security-mvc-boot/src/main/resources/templates/private.html +++ b/spring-security-mvc-boot/src/main/resources/templates/private.html @@ -1,6 +1,6 @@ + xmlns:sec="http://www.thymeleaf.org/extras/spring-security"> Private diff --git a/spring-security-openid/pom.xml b/spring-security-openid/pom.xml index 6a946792ba..4343996e02 100644 --- a/spring-security-openid/pom.xml +++ b/spring-security-openid/pom.xml @@ -9,10 +9,10 @@ Spring OpenID sample project - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 diff --git a/spring-security-openid/src/main/resources/application.properties.sample.properties b/spring-security-openid/src/main/resources/application.properties similarity index 100% rename from spring-security-openid/src/main/resources/application.properties.sample.properties rename to spring-security-openid/src/main/resources/application.properties diff --git a/spring-security-sso/pom.xml b/spring-security-sso/pom.xml index 4deab01464..4b297a91b5 100644 --- a/spring-security-sso/pom.xml +++ b/spring-security-sso/pom.xml @@ -9,10 +9,10 @@ pom - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 @@ -24,7 +24,7 @@ 3.1.0 2.3.3.RELEASE - 2.0.1.RELEASE + 2.1.1.RELEASE diff --git a/spring-security-sso/spring-security-sso-ui-2/pom.xml b/spring-security-sso/spring-security-sso-ui-2/pom.xml index 1f9a5754ae..e4ccb82fea 100644 --- a/spring-security-sso/spring-security-sso-ui-2/pom.xml +++ b/spring-security-sso/spring-security-sso-ui-2/pom.xml @@ -37,7 +37,7 @@ org.thymeleaf.extras - thymeleaf-extras-springsecurity4 + thymeleaf-extras-springsecurity5 diff --git a/spring-security-sso/spring-security-sso-ui/pom.xml b/spring-security-sso/spring-security-sso-ui/pom.xml index 56131749ba..a946db4c3b 100644 --- a/spring-security-sso/spring-security-sso-ui/pom.xml +++ b/spring-security-sso/spring-security-sso-ui/pom.xml @@ -38,7 +38,7 @@ org.thymeleaf.extras - thymeleaf-extras-springsecurity4 + thymeleaf-extras-springsecurity5 diff --git a/spring-security-thymeleaf/pom.xml b/spring-security-thymeleaf/pom.xml index 314783ebf2..d8b476683a 100644 --- a/spring-security-thymeleaf/pom.xml +++ b/spring-security-thymeleaf/pom.xml @@ -11,10 +11,10 @@ Spring Security with Thymeleaf tutorial - parent-boot-2.0-temp + parent-boot-2 com.baeldung 0.0.1-SNAPSHOT - ../parent-boot-2.0-temp + ../parent-boot-2 @@ -43,7 +43,7 @@ org.thymeleaf.extras - thymeleaf-extras-springsecurity4 + thymeleaf-extras-springsecurity5