Spring

· spring/test
문제org.mockito.exceptions.base.MockitoException: Cannot mock/spy class net.nurigo.sdk.message.service.DefaultMessageServiceMockito cannot mock/spy because : - final class@Mock을 사용해서 mocking을 하려고 했는데 해당 클래스가 final 클래스여서 mocking이 불가능한 상태였다. 해결하기 What's new in Mockito 2Most popular Mocking framework for unit tests written in Java - mockito/mockitogithub.com위의 Mockito2를 사용하면 이를 해결할 수 있다. 여기서 sample도 ..
문제org.hibernate.LazyInitializationException: could not initialize proxy [com.zb.deuggeun.programschedule.entity.ProgramTimeSlot#2] - no Session org.hibernate.LazyInitializationException은 Hibernate이 지연로딩된 엔티티를 초기화할 때 발생하는 예외다.일반적으로 Hibernate 세션이 종료된 후에 지연로딩된 엔티티를 사용하려고 할 때 발생한다. 해결하기Hibernate 세션 유지지연로딩된 엔티티를 사용하는 동안 Hibernate 세션을 열어두는 것이 가장 간단한 방법이다.이렇게 하려면 트랜잭션 범위에서 세션을 열고, 트랜잭션이 끝나기 전에 세션을 닫으면 ..
나의 오류 내용 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed ... Caused by: java.lang.RuntimeException: Could not postProcess org.springframework.security.config.annotation.web.builders.WebSecurity@443d94ae of type class org.sp..
스프링 부트 액추에이터 개발 단계 이후 운영 단계에서 정상 동작 확인을 위해 모니터링 환경을 구축해야 한다. 스프링 부트 액추에이터는 HTTP 엔드포인트나 JMX를 활용해 애플리케이션을 모니터링하고 관리할 수 있는 기능을 제공한다. 액추에이터의 환경 설정과 활용 방법에 대해 알아보자. 액추에이터 의존성 implementation 'org.springframework.boot:spring-boot-starter-actuator' 의존성은 아래에서 확인 가능하다. Production-ready Features You can enable recording of HTTP exchanges by providing a bean of type HttpExchangeRepository in your applicatio..
예외와 에러 예외(Exception) 입력 값의 처리가 불가능 하거나 참조된 값이 잘못된 경우 등 애플리케이션이 정상적으로 동작하지 못하는 상황 개발자가 직접 처리할 수 있는 것이므로 미리 코드 설계를 통한 처리가 필요하다. 에러(Error) 자바의 가상머신에서 발생시키는 것으로 예외와 달리 애플리케이션 코드에서 처리할 수 있는 것이 거의 없다. ex) 메모리 부족(OutOfMemory), 스택 오버플로(StackOverFlow) 코드를 살펴보면서 문제가 발생하지 않도록 예방해서 원천적으로 차단해야 한다. 예외 클래스 모든 예외 클래스는 Throwable 클래스를 상속받는다. Exception 클래스 구분 Exception 클래스는 다양한 자식 클래스를 가지고 있다. 크게 Checked Exception..
스프링의 유효성 검사는 주로 사용자가 입력한 데이터의 유효성을 검증하는 데 사용된다. 웹 애플리케이션에서 사용자로부터 받은 데이터가 정확하고 적절한 형식으로 제공되었는지 확인하기 위한 것이다. 예를 들어, 회원 가입 폼에서 사용자가 제공한 이메일 주소가 올바른 형식인지, 비밀번호가 일치하는지 등을 확인할 때 유효성 검사가 사용될 수 있다. 일반적인 애플리케이션 유효성 검사의 문제점 관리: 계층별로 진행하는 유효성 검사는 검증 로직이 각 클래스별로 분산돼 있어 관리가 어렵다. 중복: 검증 로직이 중복이 많아 여러 곳에 유사한 기능 코드가 존재할 수 있다. 코드 길어짐: 검증할 값이 많으면 검증 코드가 길어진다. 즉, 코드가 복잡해지고 가독성이 떨어진다. 이를 해결하기 위해 자바에서 데이터 유효성 검사 프레..
Spring Data JPA :: Spring Data JPA Oliver Gierke, Thomas Darimont, Christoph Strobl, Mark Paluch, Jay Bryant, Greg Turnquist Copies of this document may be made for your own use and for distribution to others, provided that you do not charge any fee for such copies and further provided that docs.spring.io JPQL(JPA Query Language) JPQL은 자바 영속성 쿼리 언어(Java Persistence Query Language)의 약자로, 객체 지향 데이..
Error Description: Parameter 1 of constructor in com.projectname.api.loan.request.LoanRequestServiceImpl required a bean of type 'com.projectname.domain.repository.UserInfoRepository' that could not be found. Action: Consider defining a bean of type 'com.projectname.domain.repository.UserInfoRepository' in your configuration. Error 원인 Error 내용을 확인해보면 말 그대로 스프링이 bean인식을 못하고 있기 때문에 생기는 에러이다. 에러가 발..
Error 단위 테스트 코드 작성 중 아래와 같은 오류가 떴다. Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaAuditingHandler': Cannot resolve reference to bean 'jpaMappingContext' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jpaMappingContext': Invocation of init method..
HTTP (HyperText Transfer Protocol) 클라이언트와 서버 간에 데이터를 전송하기 위한 프로토콜이다. HTTP는 주로 웹 브라우저와 웹 서버 간에 사용되며, 클라이언트가 서버로 요청을 보내고, 서버가 클라이언트에게 응답을 보내는 데 사용된다. 이러한 요청과 응답은 다양한 HTTP 메서드(Method)를 사용하여 이루어진다. 그 중에서 많이 사용하는 메서드를 스프링 컨트롤러 요청받는 방법을 알아보자. HTTP 요청 메서드 대응 어노테이션 @GetMapping, @PostMapping, @PutMapping, @DeleteMapping은 Spring MVC에서 HTTP 요청 메서드에 대응하는 어노테이션이다. 각각 GET, POST, PUT, DELETE HTTP 메서드를 처리하는 핸들러..
je-pa
'Spring' 태그의 글 목록