ΰ­¨β”ˆβ”ˆβ”ˆ Web β”ˆβ”ˆβ”ˆΰ­§/β†˜ SpringBoot 4

[Gradle] implementation, runtimeOnly, compileOnly 차이점

spring boot ν”„λ‘œμ νŠΈμ—μ„œ DB μ„ΈνŒ…μ„ ν•˜λ‹€κ°€ μ•„λž˜ gradle 섀정에 λŒ€ν•΄ 의문이 생겼닀. implementation 'org.postgresql:postgresql' runtimeOnly 'org.postgresql:postgresql' implementation은 자주 μ“°λŠ”λ° runtimeOnly와 compileOnly에 λŒ€ν•œ λͺ…ν™•ν•œ μ‚¬μš© μ‹œμ μ΄ κΆκΈˆν•΄μ‘Œλ‹€. Classpath ClasspathλŠ” ν΄λž˜μŠ€λ‚˜ jar 파일이 μ‘΄μž¬ν•˜λŠ” μœ„μΉ˜μ΄λ‹€. 크게 complileClasspath, runtimeClasspath둜 λ‚˜λˆ„μ–΄μ Έ μžˆλ‹€. compileClasspathλŠ” μ—λŸ¬μ—†μ΄ μ»΄νŒŒμΌμ„ ν•˜κΈ° μœ„ν•΄ ν•„μš”ν•œ ν΄λž˜μŠ€μ™€ jar 파일이 μœ„μΉ˜ν•œλ‹€. runtimeClasspathλŠ” μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ΄ μ •μƒμ μœΌλ‘œ μ‹€ν–‰λ˜κΈ° μœ„..

[SpringBoot] ν”„λ‘œμ νŠΈ 생성

ν”„λ‘œμ νŠΈ 생성 1. IntelliJλ₯Ό μ΄μš©ν•΄ ν”„λ‘œμ νŠΈλ₯Ό μƒμ„±ν•œλ‹€. [File] > [New] > [Project]λ₯Ό 톡해 μƒˆ ν”„λ‘œμ νŠΈλ₯Ό μƒμ„±ν•œλ‹€. 2. Spring Initializer 선택 SDK 버전을 μ„ νƒν•˜κ³  Nextλ₯Ό λˆ„λ₯Έλ‹€. 3. ν”„λ‘œμ νŠΈ λ‚΄μ˜ νŒ¨ν‚€μ§€λͺ…을 λ³€κ²½ν•˜λ €λ©΄ Group λ‚΄μš©μ„ λ°”κΏ”μ£Όλ©΄ λœλ‹€. Type은 Gradle둜 λ³€κ²½ν•΄ μ€€λ‹€. 4. μ›Ήμ„œλ²„ λ™μž‘μ„ μœ„ν•΄ 두 κ°€μ§€ 라이브러리λ₯Ό μΆ”κ°€ν•΄ μ€€λ‹€. 5. λ‹€μŒ ν™”λ©΄μ—μ„œ ν”„λ‘œμ νŠΈλͺ…을 μ„€μ •ν•˜κ³ , μ™„λ£Œλ₯Ό λˆŒλŸ¬μ€€λ‹€.

[Spring] μ˜μ‘΄μ„± μ£Όμž… (DI)

μ˜μ‘΄μ„± μ£Όμž… 방법 1) Constructor (μƒμ„±μž) ꢌμž₯ public class Test { private final LoginService loginService; private final BoardService boardService; @Autowired public Test(LoginService loginService, BoardService boardService) { this.loginService = loginService; this.boardService = boardService; } } - ν•„μˆ˜μ μΈ μ˜μ‘΄μ„± μ£Όμž…μ— μœ μš©ν•˜λ‹€. - final을 μ„ μ–Έν•  수 μžˆμœΌλ―€λ‘œ 객체가 λΆˆλ³€μ΄λ‹€. - ν…ŒμŠ€νŠΈμ½”λ“œ μž‘μ„±μ— μš©μ΄ν•˜λ‹€. 2) Setter public class Test { private Logi..

[SpringBoot] Swagger μ„€μ •ν•˜κΈ°

dependency μΆ”κ°€ λ¨Όμ € μŠ€μ›¨κ±° λ””νŽœλ˜μ‹œλ₯Ό μΆ”κ°€ν•œλ‹€. build.gradle νŒŒμΌμ— 라이브러리λ₯Ό μΆ”κ°€ν•΄μ€€λ‹€. ν•„μš”ν•œ 라이브러리의 λ””νŽœλ˜μ‹œλŠ” ν•˜μœ„ λ§ν¬μ—μ„œ μ‰½κ²Œ 찾을 수 μžˆλ‹€. https://mvnrepository.com/artifact/io.springfox/springfox-swagger2/2.9.2 Maven Repository: io.springfox » springfox-swagger2 » 2.9.2 mvnrepository.com ... repositories { mavenCentral() } dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' implementation 'org.springfra..