본문 바로가기

스프링부트5

[Spring Boot] 로깅 설정 가이드 [Spring Boot] 로깅 설정 가이드기본 로깅 설정로그 레벨 설정# application.ymllogging: level: root: INFO com.example.myapp: DEBUG org.springframework.web: WARN org.hibernate: ERROR로그 출력 형식 설정logging: pattern: console: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n" file: "%d{yyyy-MM-dd HH:mm:ss} [%thread] %-5level %logger{36} - %msg%n"파일 로깅 설정기본 파일 로깅logging: file: name: logs.. 2024. 12. 4.
[Spring Boot] application.properties vs application.yml application.properties vs application.ymlSpring Boot에서 설정 파일로 사용되는 application.properties와 application.yml의 차이점과 활용법을 알아보자. 기본 문법 비교application.properties# 서버 설정server.port=8080server.servlet.context-path=/api# 데이터베이스 설정spring.datasource.url=jdbc:mysql://localhost:3306/mydbspring.datasource.username=userspring.datasource.password=password# JPA 설정spring.jpa.hibernate.ddl-auto=updatespring.jpa.sho.. 2024. 12. 3.
[Spring] @SpringBootApplication 어노테이션 @SpringBootApplication은 아래 어노테이션을 추가한 편의성 어노테이션입니다. @Configuration 애플리케이션 컨텍스트에 대한 빈 정의 소스로 클래스에 태그를 지정합니다. @EnableAutoConfiguration Spring Boot에 클래스 경로 설정, 기타 Bean들과 다양한 property 설정을 기반으로 bean을 추가하도록 한다. 예를 들어 spring-webmvc가 클래스 경로에 있는 경우 이 어노테이션은 애플리케이션에 웹 애플리케이션으로 플래그를 지정하고 DispatcherServlet 설정과 같은 주요 동작을 활성화합니다. @ComponentScan Spring이 예를들어 com/example/demo 패키지에서 선언된 components, configuration.. 2022. 3. 15.
[Spring] 스프링 웹 어노테이션 (Spring Web Annotation) Spring에서의 Spring Web 어노테이션을 이용하여 RESTful 웹 서비스를 만들어보자. http://localhost:8080/greeting API GET 요청으로 아래의 JSON 응답을 받는 API를 작성해보자. {"id":1,"content":"Hello, World!"} 먼저 greeting 모델 클래스를 만들자. package com.example.demo; public class Greeting { private final long id; private final String content; public Greeting(long id, String content) { this.id = id; this.content = content; } public long getId() { ret.. 2022. 3. 15.