1 분 소요

Catalog Microservice

catalog-service는 사용자가 주문을 하기 전 상품 목록을 확인하기 위한 용도로 사용된다.

APIs

스크린샷 2022-10-02 오전 1 32 18

catalog-service 생성

  • Spring Boot: 2.7.4
  • dependencies
    - Spring Boot DevTools, Lombok, Spring Web, Spring Data JPA, Eureka Discovery Client, H2 Database

application.yml

server:
  port: 0

spring:
  application:
    name: catalog-service
  h2:
    console:
      enabled: true
      settings:
        web-allow-others: true
      path: /h2-console
  jpa:
    hibernate:
      ddl-auto: create-drop
    show-sql: true
    generate-ddl: true
    defer-datasource-initialization: true
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:testdb
#    username: sa
#    password: 1234

eureka:
  instance:
    instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka

#logging:
#  level:
#    com.example.catalogservice: DEBUG

Orders Microservice

APIs

order-service 생성

  • Spring Boot: 2.7.4
  • dependencies
    - Spring Boot DevTools, Lombok, Spring Web, Spring Data JPA, Eureka Discovery Client, H2 Database

application.yml

server:
  port: 0

spring:
  application:
    name: order-service
  h2:
    console:
      enabled: true
      settings:
        web-allow-others: true
      path: /h2-console
  jpa:
    hibernate:
      ddl-auto: update
  datasource:
    driver-class-name: org.h2.Driver
    url: jdbc:h2:mem:testdb
#    username: sa
#    password: 1234

eureka:
  instance:
    instance-id: ${spring.application.name}:${spring.application.instance_id:${random.value}}
  client:
    register-with-eureka: true
    fetch-registry: true
    service-url:
      defaultZone: http://localhost:8761/eureka

#logging:
#  level:
#    com.example.orderservice: DEBUG

order-serviceapplication.yml 파일은 catalog-serviceapplication.yml 파일과 거의 유사하지만,
order-service에는 초기 데이터를 넣지 않을 것이기 때문에, catalog-service에 있던 아래 코드를 변경했다.

catalog-service

spring:
  jpa:
    hibernate:
      ddl-auto: update # create-drop 에서 update 로 변경
    show-sql: true # 제거
    generate-ddl: true # 제거
    defer-datasource-initialization: true # 제거



클래스 정의 순서
Entity -> Repository -> dto, vo, Response -> service, impl ->



💛 개인 공부 기록용 블로그입니다. 👻

맨 위로 이동하기