본문 바로가기

spring9

API 문서화 : Swagger, Spring REST Docs Swagger (Springfox / Springdoc OpenAPI)API 문서화 도구OpenAPI 표준을 기반으로 동작API 자동 문서화 및 실시간 테스트 가능한 UI 제공Spring Boot에서 쉽게 설정 가능샘플 코드 (Springdoc OpenAPI)// build.gradle 의존성 추가dependencies { implementation 'org.springdoc:springdoc-openapi-ui:1.6.9'}// Spring Boot 애플리케이션 클래스@SpringBootApplicationpublic class DemoApplication { public static void main(String[] args) { SpringApplication.run(Demo.. 2025. 3. 19.
CGLIB 프록시 JDK 동적 프록시 vs CGLIB✔ Spring에서 @Transactional, @Cacheable 같은 AOP 기능을 적용할 때 JDK 동적 프록시와 CGLIB 프록시를 사용함✔ Spring Boot 2.0부터 JDK 동적 프록시가 기본값으로 변경되었으며, 그 이유와 차이를 정리CGLIB 프록시✔ CGLIB(Code Generation Library) 프록시는 바이트코드를 조작하여 클래스 기반으로 프록시 객체를 생성하는 기술✔ Spring에서는 AOP(Aspect-Oriented Programming)와 프록시 패턴에서 사용됨CGLIB 프록시 개념✔ JDK 동적 프록시와 차이점JDK 동적 프록시: 인터페이스 기반 → 인터페이스가 필요함CGLIB 프록시: 클래스 기반 → 인터페이스 없이도 프록시 생성 .. 2025. 3. 1.
[Spring] JAR & WAR JAR와 WAR 공통점JAR와 WAR 모두 Java의 jar 명령어로 생성된 압축 파일애플리케이션 관련 파일(리소스, 속성 파일 등)을 패키징하여 배포와 실행 용이 JAR (Java ARchive)목적: Java 애플리케이션 실행용 압축 파일내용: Java 클래스 파일, 라이브러리, 리소스 파일요구사항: JRE만 있으면 실행 가능 (java -jar 프로젝트명.jar)특징- 독립 실행형 애플리케이션- 내장 서버 포함 가능- 부트에서 가이드하는 표준은 JAR(JSP, 외장톰켓 사용하지 않음) WAR (Web Application ARchive)목적: 웹 애플리케이션 배포용 압축 파일내용: JSP, Servlet, JAR, 클래스 파일, XML, HTML, JavaScript 등요구사항: 웹 서버(WEB) .. 2025. 2. 11.
[Spring Boot/Gradle] spring-dev-tools 추가 1. 의존성 추가build.gradledependencies { implementation 'org.springframework.boot:spring-boot-devtools'} 2. 인텔리제이 설정 세팅Settings > Build, Execution, Deployment > Compiler > ✔️ Build project automatically Settings > Advanced Settings > ✔️ Allow auto-make to start even if developed application is currently running 3. Gradle 변경사항 업데이트 4. 프로젝트 재시작 2025. 1. 20.
Java Validation, Spring Validation Java Validation (JSR-303/JSR-380)Java Bean Validation 표준을 따름객체의 필드에 대해 유효성 검사를 선언적으로 설정할 수 있음주요 애노테이션(@NotNull, @Size, @Email 등)을 사용하여 필드의 제약 조건을 정의하고, 이를 Validator를 사용하여 실행할 수 있음주요 특징객체의 각 필드에 유효성 검사를 적용하는 애노테이션 기반의 방법@NotNull, @Size, @Min, @Max, @Email 등 다양한 기본 애노테이션 제공커스텀 유효성 검사 가능Java SE 환경에서도 사용 가능하며, Spring과 같은 다른 프레임워크와 통합 가능Java Validation 샘플 코드import javax.validation.constraints.NotNull.. 2024. 3. 25.
Spring Security Architecture / 스프링 시큐리티 구조 Authentication vs Authorization Authentication the process of validating your credentials (such as User username and password) to verify your identity and whether you are the person you claim to be, or not. Or simply put, Authentication is about knowing who you are. Authorization the process to determine whether the authenticated user has access to a particular resource. Or simply put, Authoriza.. 2023. 11. 20.
Spring Bean Life Cycle / 스프링 빈 생명주기 What is a Spring Bean? A Spring bean is a Java object managed by the Spring IoC container. Why Understand the Spring Bean Life Cycle? A solid grasp of the bean life cycle empowers you to effectively manage resources, configure beans, and ensure proper initialization and cleanup. With this knowledge, you can optimize your application’s performance, prevent memory leaks, and implement custom logic.. 2023. 11. 7.
[Spring & Boot] Message 사용법 메시지(Message) 정의 메시지 코드로 메시지 콘텐츠를 호출 message.properties 파일에서 관리(application.properties와 유사함) 구조 //{messageCode}={messageContent} labl.cate="Category" labl.mng="Management" 사용 목적 클라이언트 단에서 보여주는 문자 관리 클라이언트 언어 설정에 따른 문자 관리(다국어화) 에러 코드 및 에러 메시지 관리 메시지 설정 1. Spring MessageSource의 구현체인 ResourceBundleMessageSource를 직접 Bean에 등록해야 함 @Bean public MessageSource messageSource() { ResourceBundleMessageSource.. 2022. 3. 24.
[Spring] 로그: JNDI lookup for name [spring.liveBeansView.mbeanDomain] threw NamingException with message DB 연동 후 하기 로그 뜨는 경우: Spring의 Live Beans Graph 관련 기능 제공하는 부분에 대한 Debug성 메시지 (에러 아님) 17:29:21.649 [localhost-startStop-1] DEBUG o.springframework.jndi.JndiTemplate - Looking up JNDI object with name [java:comp/env/spring.liveBeansView.mbeanDomain] 17:29:21.649 [localhost-startStop-1] DEBUG o.s.jndi.JndiLocatorDelegate - Converted JNDI name [java:comp/env/spring.liveBeansView.mbeanDomain] not found.. 2021. 11. 16.