spring cloud : e-commerce - user service setting
This commit is contained in:
@@ -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'
|
||||
|
||||
@@ -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() ;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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.
|
||||
Reference in New Issue
Block a user