CONFIG
curl-X POST http://localhost:3100/encrypt -d "암호화할 데이터"
서비스 디스커버리 - 넷플릭스 유레카 서버
게이트웨이 서버
REST 서버
ApiServer
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
implementation 'org.modelmapper:modelmapper:3.2.1'
implementation 'com.querydsl:querydsl-jpa:5.1.0:jakarta'
annotationProcessor 'com.querydsl:querydsl-apt:5.1.0:jakarta'
annotationProcessor 'jakarta.annotation:jakarta.annotation-api'
annotationProcessor 'jakarta.persistence:jakarta.persistence-api'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testRuntimeOnly 'com.h2database:h2'
runtimeOnly 'com.oracle.database.jdbc:ojdbc11'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.named('test') {
useJUnitPlatform()
}
def querydslDir = layout.buildDirectory.dir("generated/querydsl").get().asFile
sourceSets {
main.java.srcDirs += [ querydslDir ]
}
tasks.withType(JavaCompile) {
options.getGeneratedSourceOutputDirectory().set(file(querydslDir))
}
clean.doLast {
file(querydslDir).deleteDir()
}
서비스 디스커버리 서버
유레카
:서비스를 찾아줌
까지 추가
환경변수 적용 안 돼서 임시로
이렇게함
api 추가해서 유레카 쪽에 띄울거임
환경변수 추가
유레카 서버에서 api 추가댐
유레카 데이터 확인
세큐리티 무력화 후
민감한 정보 들어있음
GateWay
3101번에 존재하지만 3000번에 존재하는 것처럼 설정한거임.
(유레카가 다 모아준거임)
주소 맵핑해줌 다른걸로 주소 검색되게
/api-sevice -> /api/v1/**로 맵핑
http://localhost:3000/actuator/gateway/routes
주소가 어떻게 맵핑되어있는지 확인 가능
admin Server
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-bootstrap'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.cloud:spring-cloud-starter-config'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.oracle.database.jdbc:ojdbc11'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
server:
port: 3002 #3001은 api
spring:
# 데이터베이스 설정
datasource:
driverClassName: oracle.jdbc.driver.OracleDriver
# driverClassName: '{cipher}536165156156165165656'
url: jdbc:oracle:thin:@${db.host}:${db.port}:XE
# url: '{cipher}536165156156165165656'
username: ${db.username}
password: ${db.password}
# JPA 설정
jpa:
properties:
hibernate:
show_sql: true
format_sql: true
use_sql_comments: true
hibernate:
ddlAuto: update
# 파일 업로드 용량 설정
servlet:
multipart:
maxFileSize: 20MB
maxRequestSize: 60MB
fileSizeThreshold: 30MB
# 정적 자원 설정(CSS, JS, 이미지)
web:
resources:
staticLocations: classpath:/static/
# 타임리프 설정
thymeleaf:
cache: true
prefix: classpath:/templates/
# 로거 설정
logging:
level:
org.hibernate.type: trace
org.hibernate.orm.jdbc.bind: trace
# 유레카 설정
eureka:
instance:
preferIpAddress: true # 아이피 먼저 체크
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: ${eurekaHost}/eureka/
# 액추에이터 설정
management:
endpoint:
health:
showDetails: always
refresh:
enabled: true
endpoints:
web:
exposure:
include: health, refresh #더 자세히 보임, 서버를 껐다키지않아도 갱신
spring:
# 라이브 리로드 설정
devtools:
livereload:
enabled: true
# 정적 자원 설정(CSS, JS, 이미지)
web:
resources:
staticLocations: file:src/main/resources/static/
# 타임리프 설정
thymeleaf:
cache: false
prefix: file:src/main/resources/templates/
spring:
# 데이터베이스 설정
datasource:
driverClassName: org.h2.Driver
url: jdbc:h2:mem:test
username: sa
password: