분류 전체보기 (44) 썸네일형 리스트형 @WebMvcTest vs @AutoConfigureMockMvc springframework의 @WebMvcTest 설명 원문:Annotation that can be used for a Spring MVC test that focuses only on Spring MVC components.Using this annotation will disable full auto-configuration and instead apply only configuration relevant to MVC tests (i.e. @Controller, @ControllerAdvice, @JsonComponent, Converter/GenericConverter, Filter, WebMvcConfigurer and HandlerMethodArgumentResolver beans but n.. 406 에러 컨트롤러 테스트를 진행했는데, 406 에러로 테스트 fail이 떨어졌다. java.lang.AssertionError: Status expected: but was: 406 error?406 Not Acceptable하이퍼텍스트 전송 프로토콜(HTTP)의 406 Not Acceptable 클라이언트 에러 응답 코드는 서버가 요청의 주도적인 콘텐츠 협상 헤더에 정의된 허용 가능한 값 목록과 일치하는 응답을 생성할 수 없으며, 서버가 기본 표현을 제공하지 않음을 나타냅니다.출처: https://developer.mozilla.org/ko/docs/Web/HTTP/Status/406 서버 응답 형식이나 값 때문에 발생하는 문제로 추정되는데, 응답을 전달하는 ResponseDto에 @Getter를 추가해서 해결.. @EnableJpaAuditing을 별도의 config 파일에 분리 시 테스트에서 인식 안되는 문제 데이터의 생성일자, 수정일자를 jpa를 통해 자동으로 넣기 위해 BaseEntity를 생성하고, entity 저장 시 등록 되는지 테스트를 해보았으나 결과값이 null로 나왔다. @EnableJpaAuditing을 Application.java에 추가하지 않고 JpaConfig 파일을 별도로 만들어서 추가한 이유는, Mock 테스트 시 사용하는 @WebMvcTest와 충돌하기 때문이다. 위의 이유로 JpaConfig 파일을 별도로 생성했으나, 문제는 테스트할 때 @EnableJpaAuditing이 인식되지 않는건지 계속 createdDate가 null로 나왔다. JpaConfig.javaimport org.springframework.context.annotation.Configuration;imp.. 이클립스 깃허브 연동 에러 해결 깃허브에 리포지터리 생성 후 리드미 작성 + 테스트용으로 몇가지 파일을 커밋해 둔 상태에서 로컬 프로젝트 생성하고 우클릭 -> [Team] -> [Share Project...] -> 깃허브 리포지터리 입력 후 push -> 폴더 째로 업로드됨. -> revert commit으로 커밋 내용 취소이후 [Team]-[Disconnect]로 연결 해제 -> 다시 [Team]-[Share Project]-[Use or create repository ~] 체크 -[Create Repository] 클릭 후 [Finish]이후에 깃허브 리포지터리와 연동해준다.Git Repository 화면에서 Remotes 폴더 우클릭 -> [Create Remote...] 클릭-> 원격저장소 이름 입력 후 [create] ->.. Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceSc 에러 전문 :Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean w.. H2 DB 연결 h2는 인메모리 관계형 데이터베이스로 별도의 설치 없이 프로젝트 의존성만으로 관리가 가능하다. 인메모리 즉, 메모리에서 실행되기 때문에 어플리케이션이 재시작될때 마다 초기화되어 주로 테스트 용도로 사용된다. 1. 의존성 주입gradle의 경우 implementation 'org.springframework.boot:spring-boot-starter-data-jpa' implementation 'com.h2database:h2' maven의 경우 org.springframework.boot spring-boot-starter-data-jpa com.h2database h2 runtime 2. 데이터베이스 구성datasource의 url, driverClassName.. JSON parse error: Cannot deserialize value of type `java.util.ArrayList<>` from Object value (token `JsonToken.START_OBJECT`); 에러 전문은 아래와 같다.JSON parse error: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`); nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `java.util.ArrayList` from Object value (token `JsonToken.START_OBJECT`) at [Source: (org.springframework.util.StreamUtils$NonClosingInputStream).. @RequestBody에 DTO 사용 시 기본 생성자를 못 찾는 에러 Cannot construct instance of '...[DTO 위치]' 에러 발생에러 내용은 대충 기본 생성자를 못 찾는다는 소리다.아래가 문제의 DTOpackage com.example.demo.dto;import java.time.LocalDateTime;import java.util.List;import lombok.AllArgsConstructor;import lombok.Builder;import lombok.Getter;import lombok.NoArgsConstructor;import lombok.ToString;@NoArgsConstructor@Getter@ToStringpublic class MeetingDto { private String topic; private int typ.. [MYSQL] UPDATE 시 날짜 자동 입력 INSERT 시 자동으로 시간값 반영(테이블 생성 시 DEFAULT 값으로 CURRENT_TIMESTAMP를 설정해도 됨) ALTER TABLE 테이블명 MODIFY columnName TIMESTAMP DEFAULT CURRENT_TIMESTAMP; UPDATE 시 자동으로 시간값 반영 ALTER TABLE 테이블명 MODIFY 컬럼명 TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; 참고한 블로그 https://hayjo.tistory.com/48 [MySQL] ALTER TABLE table ... TIMESTAMP 기존에 DATETIME으로만 지정했던 컬럼에 기본값을 넣어줄 필요가 생겼다. INSERT INTO 당시의 시간을 기본값.. javascript function에서 ajax 결과에 따라 return function check() { var isSuccess = false; $.ajax({ type: "POST", url: "...", data: data, dataType: "json" success: function(result){ if (result.result == "success") { return true; } else { return false; } } }); } 처음에 이런 식으로 ajax의 success 안에서 return을 했더니, 호출한 곳에서 undefined가 나왔다. function check() { var isSuccess = false; $.ajax({ type: "POST", url: "...", data: data, dataType: "json" success: func.. 이전 1 2 3 4 5 다음