diff --git a/README.md b/README.md index d04af99e..2aa1a26c 100644 --- a/README.md +++ b/README.md @@ -7,3 +7,4 @@ * *hibernate-fetch-mode-demo* - Hibernate, N+1 * *mongo-db-demo* - MongoDB, MongoEventListener, Mongock * *docker-test-containers* - TestContainers +* *spring-cloud-demo-stvort* - Config server, Eureka, Zuul, Feign client diff --git a/spring-cloud-demo-stvort/README.md b/spring-cloud-demo-stvort/README.md new file mode 100644 index 00000000..6c56c1fb --- /dev/null +++ b/spring-cloud-demo-stvort/README.md @@ -0,0 +1,24 @@ +# Config server, Eureka, Zuul, Feign client + +## (config-server, : 8888) +* +* Spring Config Server + +## (service-discovery-server, : 8761) +* (/) - +* Eureka + +## (greeting-microservice, : 8081) + : +* , +* (@Value) +* , . API FeignClient + +## (names-microservice, : 8082) +* , +* (@Value) + +## API (facade-gateway, : 8080) +* API +* API Spring Security +* Zuul diff --git a/spring-cloud-demo-stvort/config-server/.gitignore b/spring-cloud-demo-stvort/config-server/.gitignore new file mode 100644 index 00000000..153c9335 --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-cloud-demo-stvort/config-server/pom.xml b/spring-cloud-demo-stvort/config-server/pom.xml new file mode 100644 index 00000000..80820842 --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.4.RELEASE + + + ru.otus.example + config-server + 0.0.1-SNAPSHOT + ConfigServer + Config server + + + 1.8 + Greenwich.SR1 + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.cloud + spring-cloud-config-server + + + + org.projectlombok + lombok + true + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-cloud-demo-stvort/config-server/src/main/java/ru/otus/example/configserver/ConfigServerApplication.java b/spring-cloud-demo-stvort/config-server/src/main/java/ru/otus/example/configserver/ConfigServerApplication.java new file mode 100644 index 00000000..83b4dac4 --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/src/main/java/ru/otus/example/configserver/ConfigServerApplication.java @@ -0,0 +1,15 @@ +package ru.otus.example.configserver; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.config.server.EnableConfigServer; + +@EnableConfigServer +@SpringBootApplication +public class ConfigServerApplication { + + public static void main(String[] args) { + SpringApplication.run(ConfigServerApplication.class, args); + } + +} diff --git a/spring-cloud-demo-stvort/config-server/src/main/resources/application.yml b/spring-cloud-demo-stvort/config-server/src/main/resources/application.yml new file mode 100644 index 00000000..f71d438e --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/src/main/resources/application.yml @@ -0,0 +1,11 @@ +spring: + profiles: + active: native + cloud: + config: + server: + native: + search-locations: classpath:/config + +server: + port: 8888 diff --git a/spring-cloud-demo-stvort/config-server/src/main/resources/config/facade-gateway.yml b/spring-cloud-demo-stvort/config-server/src/main/resources/config/facade-gateway.yml new file mode 100644 index 00000000..3965ec99 --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/src/main/resources/config/facade-gateway.yml @@ -0,0 +1,19 @@ +server: + port: 8080 + +eureka: + client: + fetch-registry: true + +zuul: + prefix: "/common-api" + strip-prefix: true + routes: + greetings: + serviceId: greeting-microservice + strip-prefix: false + names: + serviceId: names-microservice + strip-prefix: false + +greeting: А я api-gateway \ No newline at end of file diff --git a/spring-cloud-demo-stvort/config-server/src/main/resources/config/greeting-microservice.yml b/spring-cloud-demo-stvort/config-server/src/main/resources/config/greeting-microservice.yml new file mode 100644 index 00000000..6322421e --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/src/main/resources/config/greeting-microservice.yml @@ -0,0 +1,8 @@ +server: + port: 8081 + +eureka: + client: + fetch-registry: true + +greeting: Всем ооочень добрый день (c) diff --git a/spring-cloud-demo-stvort/config-server/src/main/resources/config/names-microservice.yml b/spring-cloud-demo-stvort/config-server/src/main/resources/config/names-microservice.yml new file mode 100644 index 00000000..3415c71d --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/src/main/resources/config/names-microservice.yml @@ -0,0 +1,8 @@ +server: + port: 8082 + +eureka: + client: + fetch-registry: true + +default-form-of-appeal: Товарищ \ No newline at end of file diff --git a/spring-cloud-demo-stvort/config-server/src/main/resources/config/service-discovery-server.yml b/spring-cloud-demo-stvort/config-server/src/main/resources/config/service-discovery-server.yml new file mode 100644 index 00000000..7aaff777 --- /dev/null +++ b/spring-cloud-demo-stvort/config-server/src/main/resources/config/service-discovery-server.yml @@ -0,0 +1,7 @@ +server: + port: 8761 + +eureka: + client: + register-with-eureka: true + fetch-registry: false \ No newline at end of file diff --git a/spring-cloud-demo-stvort/facade-gateway/.gitignore b/spring-cloud-demo-stvort/facade-gateway/.gitignore new file mode 100644 index 00000000..153c9335 --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-cloud-demo-stvort/facade-gateway/pom.xml b/spring-cloud-demo-stvort/facade-gateway/pom.xml new file mode 100644 index 00000000..ed9c9a52 --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.4.RELEASE + + + ru.otus.example + facade-gateway + 0.0.1-SNAPSHOT + FacadeGateway + Facade gateway + + + 1.8 + Greenwich.SR1 + + + + + org.springframework.cloud + spring-cloud-config-client + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-thymeleaf + + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.cloud + spring-cloud-starter-netflix-zuul + + + + org.projectlombok + lombok + true + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/FacadeGatewayApplication.java b/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/FacadeGatewayApplication.java new file mode 100644 index 00000000..6b91080c --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/FacadeGatewayApplication.java @@ -0,0 +1,17 @@ +package ru.otus.example.facadegateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.netflix.zuul.EnableZuulProxy; + +@EnableDiscoveryClient +@EnableZuulProxy +@SpringBootApplication +public class FacadeGatewayApplication { + + public static void main(String[] args) { + SpringApplication.run(FacadeGatewayApplication.class, args); + } + +} diff --git a/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/config/SecurityConfig.java b/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/config/SecurityConfig.java new file mode 100644 index 00000000..067415a0 --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/config/SecurityConfig.java @@ -0,0 +1,70 @@ +package ru.otus.example.facadegateway.config; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.config.annotation.authentication.configuration.AuthenticationConfiguration; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.config.http.SessionCreationPolicy; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.User; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; +import org.springframework.security.crypto.password.PasswordEncoder; +import org.springframework.security.provisioning.InMemoryUserDetailsManager; + +import java.util.Collections; + +@Configuration +@EnableWebSecurity +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Autowired + private UserDetailsService userDetailsService; + + @Bean + public PasswordEncoder passwordEncoder() { + return new BCryptPasswordEncoder(); + } + + @Bean + public UserDetailsService userDetailsService(PasswordEncoder passwordEncoder) { + InMemoryUserDetailsManager inMemoryUserDetailsManager = new InMemoryUserDetailsManager(); + inMemoryUserDetailsManager.createUser(new User("cool", passwordEncoder.encode("cool"), Collections.singletonList((GrantedAuthority) () -> "USER"))); + return inMemoryUserDetailsManager; + } + + @Override + protected void configure(HttpSecurity http) throws Exception { + http.csrf().disable() + .sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS) + .and() + + .authorizeRequests().antMatchers("/", "/favicon.ico").permitAll() + .and() + + .authorizeRequests().antMatchers("/login-form-processing").anonymous() + .and() + + .authorizeRequests().antMatchers("/**").authenticated() + .and() + + .formLogin() + .loginProcessingUrl("/login-form-processing") + .usernameParameter("username-for-login") + .passwordParameter("password-for-login") + .defaultSuccessUrl("/", true) + .failureUrl("/login-form") + .and() + + .rememberMe() + .key("secret") + .userDetailsService(userDetailsService) + .alwaysRemember(true) + .tokenValiditySeconds(60) + ; + } + +} diff --git a/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/controller/MainViewController.java b/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/controller/MainViewController.java new file mode 100644 index 00000000..4a7ac9ac --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/src/main/java/ru/otus/example/facadegateway/controller/MainViewController.java @@ -0,0 +1,16 @@ +package ru.otus.example.facadegateway.controller; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +public class MainViewController { + + @GetMapping("/") + public String mainPage(Model model, @Value("${greeting}") String greeting) { + model.addAttribute("greeting", greeting); + return "index"; + } +} diff --git a/spring-cloud-demo-stvort/facade-gateway/src/main/resources/bootstrap.yml b/spring-cloud-demo-stvort/facade-gateway/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..02d6fe41 --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/src/main/resources/bootstrap.yml @@ -0,0 +1,6 @@ +spring: + application: + name: facade-gateway + cloud: + config: + fail-fast: true \ No newline at end of file diff --git a/spring-cloud-demo-stvort/facade-gateway/src/main/resources/static/favicon.ico b/spring-cloud-demo-stvort/facade-gateway/src/main/resources/static/favicon.ico new file mode 100644 index 00000000..6ffcf306 Binary files /dev/null and b/spring-cloud-demo-stvort/facade-gateway/src/main/resources/static/favicon.ico differ diff --git a/spring-cloud-demo-stvort/facade-gateway/src/main/resources/templates/index.html b/spring-cloud-demo-stvort/facade-gateway/src/main/resources/templates/index.html new file mode 100644 index 00000000..3374cfd7 --- /dev/null +++ b/spring-cloud-demo-stvort/facade-gateway/src/main/resources/templates/index.html @@ -0,0 +1,26 @@ + + + + + + Greetings microservice group API-gateway + + + + + + + +

Greetings microservice group API-gateway

+common-api/greetings/simple
+common-api/greetings/from-config-server
+common-api/greetings/from-external-service
+common-api/names/random
+

+ +
+ + \ No newline at end of file diff --git a/spring-cloud-demo-stvort/greeting-microservice/.gitignore b/spring-cloud-demo-stvort/greeting-microservice/.gitignore new file mode 100644 index 00000000..153c9335 --- /dev/null +++ b/spring-cloud-demo-stvort/greeting-microservice/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-cloud-demo-stvort/greeting-microservice/pom.xml b/spring-cloud-demo-stvort/greeting-microservice/pom.xml new file mode 100644 index 00000000..0a61c9ea --- /dev/null +++ b/spring-cloud-demo-stvort/greeting-microservice/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.4.RELEASE + + + ru.otus.example + greeting-microservice + 0.0.1-SNAPSHOT + GreetingMicroservice + Greeting microservice + + + 1.8 + 1.8 + 1.8 + Greenwich.SR1 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.cloud + spring-cloud-config-client + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + + org.projectlombok + lombok + true + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/GreetingMicroserviceApplication.java b/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/GreetingMicroserviceApplication.java new file mode 100644 index 00000000..0dddc042 --- /dev/null +++ b/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/GreetingMicroserviceApplication.java @@ -0,0 +1,17 @@ +package ru.otus.example.greetingmicroservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; + +@EnableDiscoveryClient +@EnableFeignClients +@SpringBootApplication +public class GreetingMicroserviceApplication { + + public static void main(String[] args) { + SpringApplication.run(GreetingMicroserviceApplication.class, args); + } + +} diff --git a/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/rest/GreetingRestController.java b/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/rest/GreetingRestController.java new file mode 100644 index 00000000..24e179af --- /dev/null +++ b/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/rest/GreetingRestController.java @@ -0,0 +1,29 @@ +package ru.otus.example.greetingmicroservice.rest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class GreetingRestController { + + @Autowired + private NamesMicroServiceClient namesMicroServiceClient; + + @GetMapping("greetings/simple") + public String simpleGreeting(){ + return "Нихао! Всем по нихао!"; + } + + @GetMapping("greetings/from-config-server") + public String greetingFromConfigServer(@Value("${greeting}") String greeting){ + return greeting; + } + + @GetMapping("greetings/from-external-service") + public String greetingFromEternalSservice(){ + return namesMicroServiceClient.randomName() + ": Здравствуйте и не говорите, что не здравтсвуйте!"; + } + +} diff --git a/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/rest/NamesMicroServiceClient.java b/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/rest/NamesMicroServiceClient.java new file mode 100644 index 00000000..8f2612c5 --- /dev/null +++ b/spring-cloud-demo-stvort/greeting-microservice/src/main/java/ru/otus/example/greetingmicroservice/rest/NamesMicroServiceClient.java @@ -0,0 +1,10 @@ +package ru.otus.example.greetingmicroservice.rest; + +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +@FeignClient("names-microservice") +public interface NamesMicroServiceClient { + @GetMapping("/names/random") + String randomName(); +} diff --git a/spring-cloud-demo-stvort/greeting-microservice/src/main/resources/bootstrap.yml b/spring-cloud-demo-stvort/greeting-microservice/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..39c7acc2 --- /dev/null +++ b/spring-cloud-demo-stvort/greeting-microservice/src/main/resources/bootstrap.yml @@ -0,0 +1,6 @@ +spring: + application: + name: greeting-microservice + cloud: + config: + fail-fast: true \ No newline at end of file diff --git a/spring-cloud-demo-stvort/names-microservice/.gitignore b/spring-cloud-demo-stvort/names-microservice/.gitignore new file mode 100644 index 00000000..153c9335 --- /dev/null +++ b/spring-cloud-demo-stvort/names-microservice/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-cloud-demo-stvort/names-microservice/pom.xml b/spring-cloud-demo-stvort/names-microservice/pom.xml new file mode 100644 index 00000000..4dff1f3f --- /dev/null +++ b/spring-cloud-demo-stvort/names-microservice/pom.xml @@ -0,0 +1,64 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.4.RELEASE + + + ru.otus.example + names-microservice + 0.0.1-SNAPSHOT + NamesMicroservice + Names microservice + + + 1.8 + Greenwich.SR1 + 1.8 + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.cloud + spring-cloud-config-client + + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-cloud-demo-stvort/names-microservice/src/main/java/ru/otus/example/namesmicroservice/NamesMicroserviceApplication.java b/spring-cloud-demo-stvort/names-microservice/src/main/java/ru/otus/example/namesmicroservice/NamesMicroserviceApplication.java new file mode 100644 index 00000000..845d6b9a --- /dev/null +++ b/spring-cloud-demo-stvort/names-microservice/src/main/java/ru/otus/example/namesmicroservice/NamesMicroserviceApplication.java @@ -0,0 +1,15 @@ +package ru.otus.example.namesmicroservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; + +@EnableDiscoveryClient +@SpringBootApplication +public class NamesMicroserviceApplication { + + public static void main(String[] args) { + SpringApplication.run(NamesMicroserviceApplication.class, args); + } + +} diff --git a/spring-cloud-demo-stvort/names-microservice/src/main/java/ru/otus/example/namesmicroservice/rest/GreetingNamesRestController.java b/spring-cloud-demo-stvort/names-microservice/src/main/java/ru/otus/example/namesmicroservice/rest/GreetingNamesRestController.java new file mode 100644 index 00000000..d6cf98df --- /dev/null +++ b/spring-cloud-demo-stvort/names-microservice/src/main/java/ru/otus/example/namesmicroservice/rest/GreetingNamesRestController.java @@ -0,0 +1,23 @@ +package ru.otus.example.namesmicroservice.rest; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.Random; + +@RestController +public class GreetingNamesRestController { + + private static final String[] NAMES = {"Юрий Громобоевич Бдыщ", + "Говард Инванович Врумбельшпиц", + "Лукас Люкятвойотецович Охничегожсебе", + "Демосфен Менделеевич Иртыш", "Уга Чага"}; + + @GetMapping("names/random") + public String randomName(@Value("${default-form-of-appeal}") String defaultFormOfAppeal){ + Random rand = new Random(); + return defaultFormOfAppeal + " " + NAMES[rand.nextInt(NAMES.length)]; + } + +} diff --git a/spring-cloud-demo-stvort/names-microservice/src/main/resources/bootstrap.yml b/spring-cloud-demo-stvort/names-microservice/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..80e980ef --- /dev/null +++ b/spring-cloud-demo-stvort/names-microservice/src/main/resources/bootstrap.yml @@ -0,0 +1,6 @@ +spring: + application: + name: names-microservice + cloud: + config: + fail-fast: true \ No newline at end of file diff --git a/spring-cloud-demo-stvort/service-discovery-server/.gitignore b/spring-cloud-demo-stvort/service-discovery-server/.gitignore new file mode 100644 index 00000000..153c9335 --- /dev/null +++ b/spring-cloud-demo-stvort/service-discovery-server/.gitignore @@ -0,0 +1,29 @@ +HELP.md +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +/build/ + +### VS Code ### +.vscode/ diff --git a/spring-cloud-demo-stvort/service-discovery-server/pom.xml b/spring-cloud-demo-stvort/service-discovery-server/pom.xml new file mode 100644 index 00000000..9bb1f4bd --- /dev/null +++ b/spring-cloud-demo-stvort/service-discovery-server/pom.xml @@ -0,0 +1,82 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.1.4.RELEASE + + + ru.otus.example + service-discovery-server + 0.0.1-SNAPSHOT + ServiceDiscoveryServer + Service discovery server + + + 1.8 + Greenwich.SR1 + + + + + org.springframework.boot + spring-boot-starter + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-server + + + org.springframework.cloud + spring-cloud-config-client + + + javax.xml.bind + jaxb-api + 2.2.11 + + + com.sun.xml.bind + jaxb-core + 2.2.11 + + + com.sun.xml.bind + jaxb-impl + 2.2.11 + + + javax.activation + activation + 1.1.1 + + + + + + + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-cloud-demo-stvort/service-discovery-server/src/main/java/ru/otus/example/facadegateway/ServiceDiscoveryServer.java b/spring-cloud-demo-stvort/service-discovery-server/src/main/java/ru/otus/example/facadegateway/ServiceDiscoveryServer.java new file mode 100644 index 00000000..fc205157 --- /dev/null +++ b/spring-cloud-demo-stvort/service-discovery-server/src/main/java/ru/otus/example/facadegateway/ServiceDiscoveryServer.java @@ -0,0 +1,14 @@ +package ru.otus.example.facadegateway; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer; + +@EnableEurekaServer +@SpringBootApplication +public class ServiceDiscoveryServer { + public static void main(String[] args) { + SpringApplication.run(ServiceDiscoveryServer.class, args); + } + +} diff --git a/spring-cloud-demo-stvort/service-discovery-server/src/main/resources/bootstrap.yml b/spring-cloud-demo-stvort/service-discovery-server/src/main/resources/bootstrap.yml new file mode 100644 index 00000000..a077f70b --- /dev/null +++ b/spring-cloud-demo-stvort/service-discovery-server/src/main/resources/bootstrap.yml @@ -0,0 +1,6 @@ +spring: + application: + name: service-discovery-server + cloud: + config: + fail-fast: true \ No newline at end of file