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