Exercise 4
This commit is contained in:
parent
1e2e977dda
commit
c469b2a940
|
@ -19,6 +19,10 @@
|
||||||
<groupId>com.workshop</groupId>
|
<groupId>com.workshop</groupId>
|
||||||
<artifactId>library-spring-boot-starter</artifactId>
|
<artifactId>library-spring-boot-starter</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.workshop</groupId>
|
||||||
|
<artifactId>library-slf4j</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
|
|
@ -24,6 +24,11 @@
|
||||||
<artifactId>library-stdout</artifactId>
|
<artifactId>library-stdout</artifactId>
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.workshop</groupId>
|
||||||
|
<artifactId>library-slf4j</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
package com.workshop.magic.config;
|
package com.workshop.magic.config;
|
||||||
|
|
||||||
import com.workshop.magic.service.GreetingService;
|
import com.workshop.magic.service.GreetingService;
|
||||||
|
import com.workshop.magic.service.slf4j.LoggerGreetingService;
|
||||||
import com.workshop.magic.service.stdout.StdOutGreetingService;
|
import com.workshop.magic.service.stdout.StdOutGreetingService;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
import org.springframework.boot.autoconfigure.AutoConfiguration;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
@AutoConfiguration
|
@AutoConfiguration
|
||||||
|
@ -15,8 +17,16 @@ public class GreetingAutoConfiguration {
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnMissingBean
|
@ConditionalOnMissingBean
|
||||||
@ConditionalOnClass(StdOutGreetingService.class)
|
@ConditionalOnClass(StdOutGreetingService.class)
|
||||||
|
@ConditionalOnMissingClass("com.workshop.magic.service.slf4j.LoggerGreetingService")
|
||||||
GreetingService stdOutGreetingService() {
|
GreetingService stdOutGreetingService() {
|
||||||
return new StdOutGreetingService();
|
return new StdOutGreetingService();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnClass(LoggerGreetingService.class)
|
||||||
|
GreetingService slf4jGreetingService() {
|
||||||
|
return new LoggerGreetingService();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue