전체 글 338

[Spring Exception] Spring DataIntegrityViolationException

https://www.baeldung.com/spring-dataIntegrityviolationexception Spring org.springframework.dao.DataIntegrityViolationException DataIntegrityViolationException and Spring Exception Translation Spring 예외 변환 메커니즘은 컨텍스트에서 예외 변환 빈 포스트 프로세서 빈을 정의하여 @Repository 로 주석이 달린 모든 빈에 적용할 수 있다. @Configuration public class PersistenceHibernateConfig{ @Bean public PersistenceExceptionTranslationPostProcessor exce..

Web/spring 2023.04.08

[Spring] Async Support with Spring MVC and Spring Security

https://www.baeldung.com/spring-mvc-async-security 비동기 요청에 대한 Servlet 3 과 MVC, Security 에 관련된 내용이다 참고로 Spring Security는 MVC 범위 밖에서 @Async 와 통합되고 HTTP 요청도 처리합니다. implementation 'org.springframework.boot:spring-boot-starter-security' testImplementation 'org.springframework.security:spring-security-test' Spring MVC and @Async WebAsyncManager https://docs.spring.io/spring-framework/docs/current/java..

Web/spring 2023.04.06

[Spring] A Guide To Spring Redirects

https://www.baeldung.com/spring-redirect-and-forward implementing a Redirect in Spring and will discuss the reasoning behind each strategy. Why Do a Redirect? Spring 애플리케이션에러 리디렉션을 수행해야하는 이유는 많다 양식 데이터를 POST하거나 이중 제출 문제를 해결하거나, 실행 흐름을 다른 Controller Method에 위임하는 경우 등이 있다 ** 일반적으로 Post, Redirect, Get 패턴은 이중 제출 문제를 적절하게 해결하지 못하므로 초기 제출 완료 전에 페이지를 새로 고치는 것과 같은 문제는 여전히 이중 제출로 이어진다. Redirect With the ..

Web/spring 2023.04.06

[Spring] Spring MVC Custom Validation

https://www.baeldung.com/spring-mvc-custom-validator https://www.baeldung.com/spring-boot-bean-validation 8자리 이상 11자리 이하의 전화번호 값이 제대로 들어왔는지 확인하는 Validation 을 만들어본다 The New Annotation new @interface to define our annotation @Documented @Constraint(validatedBy = ContactNumberValidator.class) @Target( { ElementType.METHOD, ElementType.FIELD }) @Retention(RetentionPolicy.RUNTIME) public @interface C..

Web/spring 2023.04.05

[Spring Security] Handle Spring Security Exceptions

https://www.baeldung.com/spring-security-exceptions Spring Security는 비즈니스 로직에 대한 호출을 제어하거나 특정 URL에 대한 HTTP 요청 액세스를 제한한다 해당 보안 계층에서 Exceptions 처리가 어떻게 진행되는지 알아보자 Authentication Success Handler Authentication Failure Handler Access Denied Handler Security Configuration This will be in charge of managing all the security configurations of the application SecurityFilterChain @Bean public SecurityFil..

Web/spring 2023.04.04

[Spring] HandlerAdapters in Spring MVC

https://www.baeldung.com/spring-mvc-handler-adapters on the various handler adapters implementations available in the Spring framework. HandlerAdapter는 Spring MVC에 유연한 방식으로 HTTP 요청 처리를 용이하게 할 수 있는 interface이다 메소드를 특정 URL에 매핑하는 HandlerMapping과 함께 사용한다 DispatcherServlet은 HandlerAdapter를 사용하여 이 메소드를 호출한다. Servlet이 메소드를 직접 호출하는게 아니다. 기본적으로 자신과 핸들러 객체 사이의 bridge 역할로 느슨한 결합(loosely coupling) 설계이다. pub..

Web/spring 2023.04.04

[JPA] 강의 들으면서 쫌쫌따리

더보기 https://youtu.be/1Q3Qtd5HZy4?list=PLwouWTPuIjUgRvSmAVlZekcyAo4zkf_TK Spring Boot + Spring Data JPA 자동설정 persistence.xml, EntityManagerFactory 스프링연동 스프링 트랜잭션 연동 EntityManager 연동 spring-boot-starter-data-jpa Repository interface를 엔티티 단위로 생성 필요한 곳에 주입해서 사용하면 된다 datasource, database 등에 대한 설정값 입력 스프링 부트에 따라 설정이 달라지니 문서를 보고 설정해주어야한다.

Web/tip 2023.04.04

[Spring Test] JUnit 5 Conditional Test Execution with Annotations

https://www.baeldung.com/junit-5-conditional-test-execution 조건부 테스트 적용 방법 Operating System Conditions 경우에 따라 OS(운영체제)에 따른 테스트 시나리오를 변경해야할 경우가 있다 @EnabledOnOs 애노테이션을 붙이고 값을 제공하면 된다. 배열 인수도 가능하다. @Test @EnabledOnOs({OS.WINDOWS, OS.MAC}) public void shouldRunBothWindowsAndMac() { //... } @DisabledOnOs는 이름에서 알 수 있듯이 OS 유형 인수에 따라 테스트를 비활성화한다. @Test @DisabledOnOs(OS.LINUX) public void shouldNotRunAtLi..

Web/spring 2023.04.03
728x90