๋ฐ˜์‘ํ˜•

๐Ÿ“‚ JAVA/Spring 5

[JAVA/SPRING] API ์‘๋‹ต ๊ณตํ†ต ํฌ๋งท ๋งŒ๋“ค๊ธฐ

๊ฐœ๋ฐœ์„ ํ•˜๋‹ค ๋ณด๋ฉด ์ˆ˜๋งŽ์€ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๊ฒŒ ๋˜๊ณ  ๋ฐœ์ƒํ•˜๋Š” ์˜ค๋ฅ˜์— ๋Œ€ํ•ด ์ ์ ˆํ•œ HTTP Status Code๋กœ ํ•ธ๋“ค๋งํ•˜๊ธฐ๋Š” ์–ด๋ ค์›€์ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ธฐ ๋•Œ๋ฌธ์— ๊ณตํ†ต์ ์ธ ํฌ๋งท์„ ๋งŒ๋“ค๊ณ  Response status์™€ message๋กœ Request์— ๋Œ€ํ•œ ์ƒํƒœ์™€ ๋ฉ”์‹œ์ง€๋ฅผ ๋Œ๋ ค์ฃผ๋Š” ์ฝ”๋“œ๋ฅผ ๋งŒ๋“ค์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ResponseStatus package com.hyuckang.springboot.utils; public enum ResponseStatus { SUCCESS, FAILURE, ERROR } ResponseDto package com.hyuckang.springboot.web.dto; import com.hyuckang.springboot.utils.ResponseStatus; import lombok.AllA..

[SpringBoot] SNAPSHOT.jar์™€ SNAPSHOT-plain.jar

SNAPSHOT.jar๋Š” ์‹คํ–‰๊ฐ€๋Šฅํ•œ ์•„์นด์ด๋ธŒ์ด๊ณ , SNAPSHOT-plain.jar๋Š” ์‹คํ–‰์ด ๋ถˆ๊ฐ€๋Šฅํ•œ ์ผ๋ฐ˜ ์•„์นด์ด๋ธŒ์ด๋‹ค. ์Šคํ”„๋ง๋ถ€ํŠธ 2.5๋ถ€ํ„ฐ ๋นŒ๋“œ์‹œ ๊ธฐ๋ณธ์ ์œผ๋กœ 2๊ฐ€์ง€ ํŒŒ์ผ์ด ๋–จ์–ด์ง€๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ, ๋นŒ๋“œ์‹œ plain.jar๋ฅผ ์ƒ์„ฑํ•˜์ง€ ์•Š์œผ๋ ค๋ฉด build.gradle์— ์•„๋ž˜ ๋‚ด์šฉ์„ ์ถ”๊ฐ€ํ•ด์ฃผ๋ฉด ๋œ๋‹ค. jar { enabled = false } ์ฐธ๊ณ  Spring Boot 2.5.0 generates plain.jar file. Can I remove it? Spring Boot Gradle Plugin Reference Guide

[SpringBoot] H2 Database ์—ฐ๊ฒฐํ•˜๊ธฐ

H2๋Š” ์ธ๋ฉ”๋ชจ๋ฆฌ ๊ธฐ๋ฐ˜์˜ JAVA ๋ฐ์ดํ„ฐ ๋ฒ ์ด์Šค๋กœ, ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ฐœ๋ฐœํ•˜๋Š” ๋‹จ๊ฒŒ์—์„œ ๋งŽ์ด ์‚ฌ์šฉ์ด ๋ฉ๋‹ˆ๋‹ค. ์•„๋ž˜๋Š” H2 ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋ฅผ ํ™œ์„ฑํ™” ํ•˜๊ณ  SpringBoot์™€ H2์™€ ์—ฐ๊ฒฐํ•˜๋Š” ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ํ™˜๊ฒฝ Gradle 7.3.3 Spring Boot 2.6.4 build.gradle dependencies { runtimeOnly 'com.h2database:h2' } application.yml spring: h2: console.enabled: true datasource: url: jdbc:h2:mem:testdb username: sa password: driver-class-name: org.h2.Driver h2 ์ ‘์†๋ฐฉ๋ฒ• ์›น ๋ธŒ๋ผ์šฐ์ €๋ฅผ ์ด์šฉํ•˜์—ฌ url:{ํฌํŠธ}/h2-conosle๋กœ ์ ‘์†..

[SpringBoot] application ์„ค์ •ํŒŒ์ผ ๋ถ„๋ฆฌ

ํ™˜๊ฒฝ Gradle 7.3.3 Spring Boot 2.6.3 application ์„ค์ •ํŒŒ์ผ ๋ถ„๋ฆฌ ์•„๋ž˜ ์‚ฌ์ง„๊ณผ ๊ฐ™์ด application-{ํ™˜๊ฒฝ ์ด๋ฆ„}.yml ์œผ๋กœ ์ž‘์„ฑํ•˜๊ณ  application.yml์—์„œ ํ™œ์„ฑํ™” ํ•  ํ™˜๊ฒฝ ์ด๋ฆ„์„ ๋ช…์‹œํ•˜๋ฉด ๋œ๋‹ค. application.yml spring: profiles.active: dev application-prod.yml server: port: 1234 application-dev.yml server: port: 5678

[SpringBoot] ์Šคํ”„๋ง๋ถ€ํŠธ ํ”„๋กœ์ ํŠธ ์‹œ์ž‘ํ•˜๊ธฐ

start.spring.io ์—์„œ ํ”„๋กœ์ ํŠธ ๋‹ค์šด๋กœ๋“œ zip ์••์ถ• ํ•ด์ œ ํ›„ Maven Project๋Š” pom.xml์œผ๋กœ ,Gradle Project๋Š” build.gradle์œผ๋กœ ํ”„๋กœ์ ํŠธ ์˜คํ”ˆ(Open as Project) ํ”„๋กœ์ ํŠธ ๋นŒ๋“œ ๋ฐ ์‹คํ–‰ ๋นŒ๋“œ ํ•˜๋Š” ๋ฒ• : ./gradlew build ๋นŒ๋“œ ๊ฒฐ๊ณผ๋Š” ./build/lib/ ์— ์œ„์น˜ํ•˜๊ฒŒ ๋จ ์‹คํ–‰ : java -jar {๋นŒ๋“œ ๊ฒฐ๊ณผ๋ฌผ}.jar ๋นŒ๋“œ ํด๋ฆฐ : ./gradlew clean ํด๋ฆฐํ•˜๊ณ  ๋นŒ๋“œ : ./gradlew clean build

๋ฐ˜์‘ํ˜•