From 9ff8a53c7dcf0deb47c11b49a4809fa5b9ba6dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Valero=20S=C3=A1nchez?= Date: Thu, 11 Jan 2018 08:27:15 +0000 Subject: [PATCH] BAEL-1430: Move Spring Boot 2 actuator module --- pom.xml | 1 - spring-5/pom.xml | 4 + ...nstreamServiceReactiveHealthIndicator.java | 2 +- .../baeldung/actuator}/FeaturesEndpoint.java | 2 +- .../actuator}/InfoWebEndpointExtension.java | 2 +- .../com/baeldung/security/SecurityConfig.java | 1 + .../src/main/resources/application.properties | 2 + .../ActuatorInfoIntegrationTest.java | 13 +- spring-boot-2-actuator/.gitignore | 4 - spring-boot-2-actuator/README.MD | 0 spring-boot-2-actuator/pom.xml | 166 ------------------ .../org/baeldung/ActuatorApplication.java | 12 -- .../org/baeldung/config/SecurityConfig.java | 32 ---- .../src/main/resources/application.properties | 3 - 14 files changed, 16 insertions(+), 228 deletions(-) rename {spring-boot-2-actuator/src/main/java/org/baeldung => spring-5/src/main/java/com/baeldung/actuator}/DownstreamServiceReactiveHealthIndicator.java (95%) rename {spring-boot-2-actuator/src/main/java/org/baeldung => spring-5/src/main/java/com/baeldung/actuator}/FeaturesEndpoint.java (97%) rename {spring-boot-2-actuator/src/main/java/org/baeldung => spring-5/src/main/java/com/baeldung/actuator}/InfoWebEndpointExtension.java (96%) rename {spring-boot-2-actuator/src/test/java/org/baeldung/config => spring-5/src/test/java/com/baeldung/actuator}/ActuatorInfoIntegrationTest.java (81%) delete mode 100644 spring-boot-2-actuator/.gitignore delete mode 100644 spring-boot-2-actuator/README.MD delete mode 100644 spring-boot-2-actuator/pom.xml delete mode 100644 spring-boot-2-actuator/src/main/java/org/baeldung/ActuatorApplication.java delete mode 100644 spring-boot-2-actuator/src/main/java/org/baeldung/config/SecurityConfig.java delete mode 100644 spring-boot-2-actuator/src/main/resources/application.properties diff --git a/pom.xml b/pom.xml index 18ccfe7242..8906b1c8d2 100644 --- a/pom.xml +++ b/pom.xml @@ -150,7 +150,6 @@ spring-batch spring-bom spring-boot - spring-boot-2-actuator spring-boot-keycloak spring-boot-bootstrap spring-cloud-data-flow diff --git a/spring-5/pom.xml b/spring-5/pom.xml index ac49e8d6f4..7acee1878f 100644 --- a/spring-5/pom.xml +++ b/spring-5/pom.xml @@ -39,6 +39,10 @@ org.springframework.boot spring-boot-starter-webflux + + org.springframework.boot + spring-boot-starter-actuator + org.projectreactor reactor-spring diff --git a/spring-boot-2-actuator/src/main/java/org/baeldung/DownstreamServiceReactiveHealthIndicator.java b/spring-5/src/main/java/com/baeldung/actuator/DownstreamServiceReactiveHealthIndicator.java similarity index 95% rename from spring-boot-2-actuator/src/main/java/org/baeldung/DownstreamServiceReactiveHealthIndicator.java rename to spring-5/src/main/java/com/baeldung/actuator/DownstreamServiceReactiveHealthIndicator.java index 95cc43f976..5f36330ff6 100644 --- a/spring-boot-2-actuator/src/main/java/org/baeldung/DownstreamServiceReactiveHealthIndicator.java +++ b/spring-5/src/main/java/com/baeldung/actuator/DownstreamServiceReactiveHealthIndicator.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.actuator; import org.springframework.boot.actuate.health.Health; import org.springframework.boot.actuate.health.ReactiveHealthIndicator; diff --git a/spring-boot-2-actuator/src/main/java/org/baeldung/FeaturesEndpoint.java b/spring-5/src/main/java/com/baeldung/actuator/FeaturesEndpoint.java similarity index 97% rename from spring-boot-2-actuator/src/main/java/org/baeldung/FeaturesEndpoint.java rename to spring-5/src/main/java/com/baeldung/actuator/FeaturesEndpoint.java index 0b13bfe737..2ed32501ae 100644 --- a/spring-boot-2-actuator/src/main/java/org/baeldung/FeaturesEndpoint.java +++ b/spring-5/src/main/java/com/baeldung/actuator/FeaturesEndpoint.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.actuator; import org.springframework.boot.actuate.endpoint.annotation.*; import org.springframework.stereotype.Component; diff --git a/spring-boot-2-actuator/src/main/java/org/baeldung/InfoWebEndpointExtension.java b/spring-5/src/main/java/com/baeldung/actuator/InfoWebEndpointExtension.java similarity index 96% rename from spring-boot-2-actuator/src/main/java/org/baeldung/InfoWebEndpointExtension.java rename to spring-5/src/main/java/com/baeldung/actuator/InfoWebEndpointExtension.java index 49d88047d4..acd92d1846 100644 --- a/spring-boot-2-actuator/src/main/java/org/baeldung/InfoWebEndpointExtension.java +++ b/spring-5/src/main/java/com/baeldung/actuator/InfoWebEndpointExtension.java @@ -1,4 +1,4 @@ -package org.baeldung; +package com.baeldung.actuator; import org.springframework.boot.actuate.endpoint.annotation.ReadOperation; import org.springframework.boot.actuate.endpoint.web.WebEndpointResponse; diff --git a/spring-5/src/main/java/com/baeldung/security/SecurityConfig.java b/spring-5/src/main/java/com/baeldung/security/SecurityConfig.java index a9e44a2eee..d31f1552fc 100644 --- a/spring-5/src/main/java/com/baeldung/security/SecurityConfig.java +++ b/spring-5/src/main/java/com/baeldung/security/SecurityConfig.java @@ -17,6 +17,7 @@ public class SecurityConfig { public SecurityWebFilterChain securitygWebFilterChain(ServerHttpSecurity http) { return http.authorizeExchange() .pathMatchers("/admin").hasAuthority("ROLE_ADMIN") + .pathMatchers("/actuator/**").permitAll() .anyExchange().authenticated() .and().formLogin() .and().build(); diff --git a/spring-5/src/main/resources/application.properties b/spring-5/src/main/resources/application.properties index ccec014c2b..a7e3ec0d5a 100644 --- a/spring-5/src/main/resources/application.properties +++ b/spring-5/src/main/resources/application.properties @@ -1,3 +1,5 @@ server.port=8081 +management.endpoints.web.expose=* +info.app.name=Spring Boot 2 actuator Application logging.level.root=INFO \ No newline at end of file diff --git a/spring-boot-2-actuator/src/test/java/org/baeldung/config/ActuatorInfoIntegrationTest.java b/spring-5/src/test/java/com/baeldung/actuator/ActuatorInfoIntegrationTest.java similarity index 81% rename from spring-boot-2-actuator/src/test/java/org/baeldung/config/ActuatorInfoIntegrationTest.java rename to spring-5/src/test/java/com/baeldung/actuator/ActuatorInfoIntegrationTest.java index ff80614d10..964cf1a1ea 100644 --- a/spring-boot-2-actuator/src/test/java/org/baeldung/config/ActuatorInfoIntegrationTest.java +++ b/spring-5/src/test/java/com/baeldung/actuator/ActuatorInfoIntegrationTest.java @@ -1,6 +1,6 @@ -package org.baeldung.config; +package com.baeldung.actuator; -import org.baeldung.ActuatorApplication; +import com.baeldung.jsonb.Spring5Application; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; @@ -8,15 +8,14 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; -import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import static org.junit.Assert.*; + import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Paths; + +import static org.junit.Assert.assertEquals; @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ActuatorApplication.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Spring5Application.class) public class ActuatorInfoIntegrationTest { @Autowired diff --git a/spring-boot-2-actuator/.gitignore b/spring-boot-2-actuator/.gitignore deleted file mode 100644 index 60be5b80aa..0000000000 --- a/spring-boot-2-actuator/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -/target/ -.settings/ -.classpath -.project diff --git a/spring-boot-2-actuator/README.MD b/spring-boot-2-actuator/README.MD deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/spring-boot-2-actuator/pom.xml b/spring-boot-2-actuator/pom.xml deleted file mode 100644 index a0ae6e59a2..0000000000 --- a/spring-boot-2-actuator/pom.xml +++ /dev/null @@ -1,166 +0,0 @@ - - 4.0.0 - com.baeldung - spring-boot-actuator - 0.0.1-SNAPSHOT - jar - spring-boot - This is simple boot application for Spring boot actuator test - - - - org.springframework.boot - spring-boot-starter-parent - 2.0.0.M7 - - - - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-security - - - org.springframework.boot - spring-boot-starter-webflux - - - - org.springframework.boot - spring-boot-starter-test - test - - - io.projectreactor - reactor-test - test - - - org.springframework.security - spring-security-test - test - - - - - spring-boot-2-actuator - - - src/main/resources - true - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.7.0 - - 1.8 - 1.8 - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - **/*IntegrationTest.java - - - - - - - - - - - integration - - - - org.apache.maven.plugins - maven-surefire-plugin - - - integration-test - - test - - - - **/*IntegrationTest.java - - - - - - - json - - - - - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - - spring-snapshots - Spring Snapshots - https://repo.spring.io/snapshot - - true - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - false - - - - - - org.baeldung.ActuatorApplication - UTF-8 - 1.8 - - - diff --git a/spring-boot-2-actuator/src/main/java/org/baeldung/ActuatorApplication.java b/spring-boot-2-actuator/src/main/java/org/baeldung/ActuatorApplication.java deleted file mode 100644 index 39483c0260..0000000000 --- a/spring-boot-2-actuator/src/main/java/org/baeldung/ActuatorApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package org.baeldung; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class ActuatorApplication { - - public static void main(String[] args) { - SpringApplication.run(ActuatorApplication.class, args); - } -} diff --git a/spring-boot-2-actuator/src/main/java/org/baeldung/config/SecurityConfig.java b/spring-boot-2-actuator/src/main/java/org/baeldung/config/SecurityConfig.java deleted file mode 100644 index cc2485577e..0000000000 --- a/spring-boot-2-actuator/src/main/java/org/baeldung/config/SecurityConfig.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.baeldung.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.security.config.annotation.web.reactive.EnableWebFluxSecurity; -import org.springframework.security.config.web.server.ServerHttpSecurity; -import org.springframework.security.core.userdetails.MapReactiveUserDetailsService; -import org.springframework.security.core.userdetails.User; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.web.server.SecurityWebFilterChain; - -@EnableWebFluxSecurity -public class SecurityConfig { - - @Bean - public SecurityWebFilterChain securityWebFilterChain( - ServerHttpSecurity http) { - return http.authorizeExchange() - // We'll open up all actuator endpoints for demo purposes - .pathMatchers("/actuator/**").permitAll() - .anyExchange().authenticated() - .and().build(); - } - - @Bean - public MapReactiveUserDetailsService userDetailsService() { - UserDetails user = User.withDefaultPasswordEncoder() - .username("user").password("password").roles("USER") - .build(); - return new MapReactiveUserDetailsService(user); - } - -} diff --git a/spring-boot-2-actuator/src/main/resources/application.properties b/spring-boot-2-actuator/src/main/resources/application.properties deleted file mode 100644 index 16e1269a2a..0000000000 --- a/spring-boot-2-actuator/src/main/resources/application.properties +++ /dev/null @@ -1,3 +0,0 @@ -management.endpoints.web.expose=* - -info.app.name=Spring Boot 2 actuator Application \ No newline at end of file