Exercise 2
This commit is contained in:
parent
bd98dab588
commit
7ccc2fb465
|
@ -15,10 +15,18 @@
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.workshop</groupId>
|
||||||
|
<artifactId>library-autoconfigure</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.workshop</groupId>
|
<groupId>com.workshop</groupId>
|
||||||
<artifactId>library-api</artifactId>
|
<artifactId>library-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.workshop</groupId>
|
||||||
|
<artifactId>library-stdout</artifactId>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter</artifactId>
|
<artifactId>spring-boot-starter</artifactId>
|
||||||
|
|
|
@ -2,9 +2,7 @@ package com.workshop.magic.app;
|
||||||
|
|
||||||
import com.workshop.magic.service.AbstractGreetingService;
|
import com.workshop.magic.service.AbstractGreetingService;
|
||||||
|
|
||||||
import org.springframework.stereotype.Service;
|
//@Service
|
||||||
|
|
||||||
@Service
|
|
||||||
class MyGreetingService extends AbstractGreetingService {
|
class MyGreetingService extends AbstractGreetingService {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,4 +13,20 @@
|
||||||
|
|
||||||
<artifactId>library-autoconfigure</artifactId>
|
<artifactId>library-autoconfigure</artifactId>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.workshop</groupId>
|
||||||
|
<artifactId>library-api</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.workshop</groupId>
|
||||||
|
<artifactId>library-stdout</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.workshop.magic.config;
|
||||||
|
|
||||||
|
import com.workshop.magic.service.GreetingService;
|
||||||
|
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.context.annotation.Bean;
|
||||||
|
|
||||||
|
@AutoConfiguration
|
||||||
|
@ConditionalOnClass(GreetingService.class)
|
||||||
|
public class GreetingAutoConfiguration {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
@ConditionalOnClass(StdOutGreetingService.class)
|
||||||
|
GreetingService stdOutGreetingService() {
|
||||||
|
return new StdOutGreetingService();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
com.workshop.magic.config.GreetingAutoConfiguration
|
Loading…
Reference in New Issue