Finish!
This commit is contained in:
parent
7626d5ccb3
commit
fa77e2057c
|
@ -28,6 +28,11 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-properties-migrator</artifactId>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -38,5 +38,27 @@
|
|||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<annotationProcessorPaths>
|
||||
<path>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</path>
|
||||
</annotationProcessorPaths>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
|
|
@ -22,7 +22,7 @@ public class GreetingAutoConfiguration {
|
|||
@ConditionalOnClass(StdOutGreetingService.class)
|
||||
@ConditionalOnProperty(name = "workshop.greeting.type", havingValue = "stdout", matchIfMissing = true)
|
||||
GreetingService stdOutGreetingService(GreetingProperties properties) {
|
||||
return new StdOutGreetingService(properties.getText());
|
||||
return new StdOutGreetingService(properties.getPrefix());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -30,7 +30,7 @@ public class GreetingAutoConfiguration {
|
|||
@ConditionalOnClass(LoggerGreetingService.class)
|
||||
@ConditionalOnProperty(name = "workshop.greeting.type", havingValue = "logger")
|
||||
GreetingService slf4jGreetingService(GreetingProperties properties) {
|
||||
return new LoggerGreetingService(properties.getText());
|
||||
return new LoggerGreetingService(properties.getPrefix());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -38,6 +38,6 @@ public class GreetingAutoConfiguration {
|
|||
@MyCustomCondition
|
||||
@ConditionalOnClass(BeepGreetingService.class)
|
||||
GreetingService beepGreetingService(GreetingProperties properties) {
|
||||
return new BeepGreetingService(properties.getText());
|
||||
return new BeepGreetingService(properties.getPrefix());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,21 @@
|
|||
package com.workshop.magic.config;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
|
||||
|
||||
@ConfigurationProperties(prefix = "workshop.greeting")
|
||||
public class GreetingProperties {
|
||||
private String text = "Hello";
|
||||
private Type type = Type.STDOUT;
|
||||
private String prefix = "Hello";
|
||||
|
||||
@DeprecatedConfigurationProperty(replacement = "workshop.greeting.prefix")
|
||||
@Deprecated
|
||||
public String getText() {
|
||||
return this.text;
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
this.prefix = text;
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
|
@ -23,6 +26,14 @@ public class GreetingProperties {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
return this.prefix;
|
||||
}
|
||||
|
||||
public void setPrefix(String prefix) {
|
||||
this.prefix = prefix;
|
||||
}
|
||||
|
||||
public enum Type {
|
||||
STDOUT,
|
||||
LOGGER,
|
||||
|
|
Loading…
Reference in New Issue