spring cloud : e-commerce - user service setting

This commit is contained in:
haerong22
2021-09-18 19:34:11 +09:00
parent 9070918d4f
commit 3443ecadbf
4 changed files with 55 additions and 1 deletions

View File

@@ -25,6 +25,8 @@ ext {
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
runtimeOnly group: 'com.h2database', name: 'h2', version: '1.3.176'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'

View File

@@ -0,0 +1,26 @@
package com.example.userservice.controller;
import com.example.userservice.vo.Greeting;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequiredArgsConstructor
@RequestMapping("/")
public class UserController {
private final Greeting greeting;
@GetMapping("/health_check")
public String status() {
return "It's working in User Service";
}
@GetMapping("/welcome")
public String welcome() {
return greeting.getMessage() ;
}
}

View File

@@ -0,0 +1,17 @@
package com.example.userservice.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Greeting {
@Value("${greeting.message}")
private String message;
}

View File

@@ -4,12 +4,21 @@ server:
spring:
application:
name: user-service
h2:
console:
enabled: true
settings:
web-allow-others: true
path: /h2-console
eureka:
instance:
instance-id: ${spring.cloud.client.hostname}:${spring.application.instance_id:${random.value}}
instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://127.0.0.1:8761/eureka #등록 위치
greeting:
message: Welcome to Simple E-commerce.