Update samples to use configuration properties scanning
Closes gh-12602
This commit is contained in:
@@ -18,10 +18,8 @@ package sample.actuator.noweb;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class SampleActuatorNoWebApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -20,11 +20,9 @@ import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class SampleActuatorApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.util.function.Consumer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.dsl.IntegrationFlow;
|
||||
@@ -31,7 +30,6 @@ import org.springframework.integration.file.FileReadingMessageSource;
|
||||
import org.springframework.integration.file.FileWritingMessageHandler;
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
public class SampleIntegrationApplication {
|
||||
|
||||
private final ServiceProperties serviceProperties;
|
||||
|
||||
@@ -21,7 +21,6 @@ import java.util.function.Consumer;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
@@ -42,7 +41,6 @@ public class SampleParentContextApplication {
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableAutoConfiguration
|
||||
@EnableConfigurationProperties(ServiceProperties.class)
|
||||
protected static class Parent {
|
||||
|
||||
private final ServiceProperties serviceProperties;
|
||||
|
||||
@@ -17,10 +17,8 @@
|
||||
package sample.propertyvalidation;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "sample")
|
||||
@Validated
|
||||
public class SampleProperties {
|
||||
|
||||
@@ -19,11 +19,9 @@ package sample.simple;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
@Validated
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "sample")
|
||||
public class SampleConfigurationProperties {
|
||||
|
||||
|
||||
@@ -17,14 +17,12 @@
|
||||
package sample.test.service;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Properties for the service.
|
||||
*
|
||||
* @author Phillip Webb
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties
|
||||
public class ServiceProperties {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user