전체 글

모르는 내용 및 아는 내용 모두 꼼꼼히 복습하여 익숙해지는 그 날까지 꾸준히 공부하겠습니다.
Spring Framework/Spring

Spring StdSerializer, @JsonSerializer 커스텀 직렬화 처리 방법

StdSerializerBean class used by all standard serializers, and can also be used for custom serializers.즉, 객체를 JSON으로 직렬화할 때 사용하는 커스텀 직렬화 로직을 구현할 수 있게 도와주는 추상 클래스이다. ObjectMapper may not handle your domain correctly. You can structure your data in so many ways that you may find your own domain model does not correctly translate to JSON. StdSerializer는 제네릭 타입 T를 받아들입니다. T는 직렬화하려는 대상 객체의 타입을 나타냅니다.주..

Spring Framework/Spring

Spring Scope 어노테이션으로 빈 라이프사이클 이해하기 - prototype, request, session

Sigleton Scopethe container creates a single instance of that bean all requests for that bean name will return the same object. Any modifications to the object will be reflected in all references to the bean. This scope is the default value if no other scope is specified.Sigleton Scope인 경우 빈에 대한 모든 요청은 같은 객체를 반환합니다.객체에 대한 어떤 변경이 있는 경우 빈을 참조하는 다른 곳에도 반영이 됩니다.즉, 싱글톤 방식으로 빈을 관리합니다.@Bean@Scope("sing..

Spring Framework/Spring

스프링 FactoryBean: 생성자 주입과 필드 주입 시 프록시 객체의 동작 차이

FactoryBean을 구현한 클래스에서 @Transactional을 적용한 메서드를 가진 Service 클래스를 주입받을 때 생성자 주입과 필드 주입 방식에 있어 발생하는 차이점에 대해 정리하고자 합니다. 일반적인 빈 생성의 경우에는 생성자 주입과 필드 주입 2가지 경우 모두 AOP 프록시 객체가 잘 전달이 되는데 위 상황에서는 다르게 동작하는 것을 발견했습니다. 0. Given:/** Foo.java */@RequiredArgsConstructorpublic class Foo { private final FooService fooService; public void bar() { fooService.bar(); }}/** FooService.java */@Servicepublic class..

Spring Framework/Spring

Spring AOP 개념 정리 및 Aspect 적용 방법 - annotation 활용

AOP (Aspect Oriented Programming)OOP 개발을 하면 핵심 기능과 부가 기능이 나뉘는데, AOP는 부가 기능을 관점(Aspect)으로 정의하여, 핵심 기능에서 부가 기능을 분리하여 설계하고 구현할 수 있게 도와줍니다. 부가 기능은 핵심 기능을 도와주는 기능으로 모듈화 되어 핵심 기능과 분리되어 구현할 수 있습니다.Class A { method a() { AAAA business Logic.. BBBB } method b() { AAAA business Logic.. BBBB }} Class B { me..

Spring Framework/Spring

[Spring] 스프링 FactoryBean 이해하기 - Custom Bean 생성방법

FactoryBean이란BeanFactory내에 사용되는 객체가 구현할 인터페이스입니다.해당 인터페이스를 구현하는 경우, bean instance 자체로 노출되어 사용되는 것이 아니라, 객체를 노출할 factory로 사용됩니다.Interface to be implemented by objects used within a BeanFactory which are themselves factories for individual objects. If a bean implements this interface, it is used as a factory for an object to expose, not directly as a bean instance that will be exposed itself. 스프링 ..

Spring Framework/Spring boot

[SpringBoot] Spring에서 @Transactional과 try-catch 사용 시 롤백되지 않는 이유

요약내용!@Transactional과 try-catch를 같이 사용하면 예외가 발생해도 트랜잭션이 자동으로 롤백되지 않는 문제가 있습니다. 이는 트랜잭션의 롤백은 @Transactional 메서드가 예외를 던질 때만 발생하고, try-catch로 예외를 잡아버리면 트랜잭션이 정상적으로 커밋되기 때문입니다. @Transactional와 트랜잭션 처리트랜잭션 처리는 한 번에 이루어져야 하는 작업의 묶음으로 전체가 완료되거나 실패되는 처리를 의미합니다. (트랜잭션 처리에서 일부 성공은 허용되지 않음)@Transactionalpublic void test() { aService.doA(); bService.doB(); cService.doC();}doA(), doB(), doC()를 순차적으로 실행할 때,..

Spring Framework/Spring

[Spring] Spring Batch Tasklet 작업 단위 이해하기 - StepContribution, ChunkContext

Tasklet이란간단한 단위의 작업을 수행하는 Batch Step을 정의할 때 사용하는 인터페이스입니다,.Step은 보통 Tasklet, Chunk 단위로 작업을 처리합니다.Tasklet은 하나의 작업 단위를 처리하는 인터페이스배치 작업에서 독립적이고 작은 단위의 작업을 정의하는데 사용합니다. Tasklet Interface 구조execute() 단일 메서드를 가지고 있습니다.public interface Tasklet { RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception;}매개변수 : StepContribution, ChunkContext반환값 : RepeatStatusRepe..

트러블슈팅

H2 Database TINYINT(1) 설정 오류 해결: CommandAcceptanceException 및 JdbcSQLSyntaxErrorException 해결 방법

문제 상황Repository 테스트 코드 작성을 위해 H2 데이터베이스 세팅 중 JPA를 통한 Table 생성 오류가 발생하였습니다.h2 데이터베이스에서 TINYINT형을 지원하지만, @Column(columnDefinition = "TINYINT(1)") 처럼 길이를 제한하는 경우는 인식을 하지 못하는 문제였습니다.@Column(columnDefinition = "TINYINT", length=1) 로 설정해도 제대로 길이를 제한이 되지 않음// @Column(columnDefinition = "TINYINT(1)")// @Column(columnDefinition = "TINYINT", length = 1)@Column(columnDefinition = "TINYINT")private Integer ..

kylo
오늘도 열심히 - BE