본문 바로가기

JAVA

(52)
[Swagger] spring boot - No mapping for GET /swagger-ui 동일한 설정의 다른 프로젝트는 정상 작동 하는데, 신규 프로젝트만 해당 오류가 발생한다. Spring fox - Swagger2(2.9.x) 를 사용하는 경우 발생하는 현상이며, Spring boot 의 Configuration 을 통해 ResourceHandler를 Override 해서 swagger-ui.html 페이지의 위치를 설정해줘야 한다. Swagger 3버전에서는 해당 설정이 아닌 http://localhost:{ip}/swagger-ui/index.html 로 접속해야 함. @Configuration @EnableSwagger2 public class SwaggerConfig extends WebMvcConfiguarationSupport { @Override protected void a..
[Swagger] Error - org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; Spring boot 2.6 이후에 spring.mvc.pathmatch.matching-strategy 값이 ant_apth_matcher에서 path_pattern_parser로 변경되면서 몇몇 라이브러리(swagger포함)에 오류가 발생. application.yml - 설정 추가 spring: mvc: pathmatch: matching-strategy: ant_path_matcher + Spring boot 와 Swagger 의 버전 호환 문제도 있다고 한다. Swagger 2.9.2 버전은 S..
[JPA] Entity PK 복합키 사용 - 직렬화 복합키 생성 시 직렬화(Serializable) 가 필요하다. 데이터 교환을 위해 존재하는데 직렬화 하지 않는 경우 해당 에러가 발생한다. Composite-id class must implement Serializable: "" JPA에서 직렬화를 해야하는 이유 https://www.inflearn.com/questions/17117 Serializable 질문 드립니다 - 인프런 | 질문 & 답변 강의를 역시나 재미나게 보고 있습니다 ㅎㅎ 가끔 블로그를 보면 entity에 Serializable을 붙이는 경우가 있는데 이것에 대한 설명 부탁드립니다. 제가 아는 한에서 Serializable은 객체를 다른 서버로(ip www.inflearn.com @Entity @Builder @Data @NoArgs..
[Spring] context:component-scan 사용법 component-scan 이란? 빈으로 등록 될 클래스들을 스캔하여 빈으로 등록해주는 것이다. default - @Controller, @Service, @Component, @Repository 기본적으로 @Component 를 빈 등록 대상으로 포함한다. @Controller , @Service는 어떻게 인식하는 걸까? @Controller, @Service 가 @Component를 포함하고 있기 때문이다. 1. xml 파일 설정 base-package 기준으로 클래스들을 스캔하여 빈으로 등록한다. 여러개의 패키지를 쓸 수 있다. ex) 위와 같이 설정하면 base-package 하위의 @Controller, @Service, @Component, @Repository 모두 빈으로 등록된다. 특정한..
[API] Swagger @ApiResponse Multi 사용법 @ApiResponse 란? 해당 Method의 Response 내용을 변경해준다. Config 에서 ResponseMessage 처리 하는 것과 동일하다. 각 Method별 에러코드 별도 지정이 가능하다. (코드가 길어짐) @ApiImplicitParam과 동일하게 복수 사용이 가능하다. 코드 별 지정이 가능하나, 동일한 코드에 Message를 담아야 하는 경우는 어떻게 해야할까? @GetMapping(value="/codegroup") @ApiResponses({ @ApiResponse(code=200, message="성공입니다."), @ApiResponse(code=400, message="비정상적인 접근입니다."), @ApiResponse(code=400, message="등록 되지 않은 유저입..
[API] Spring boot Swagger 기본 사용법 https://swagger.io/ API Documentation & Design Tools for Teams | Swagger swagger.io Swagger UI 란 ? 별도의 코드 추가 없이 OpenAPI 규격에 맞게 자동으로 API를 시각화 시켜준다. Spring - Rest API를 개발 하고 API에 대한 문서를 정리 / 공유해야 할 때 Swagger를 사용하면 보다 편리해진다. API 문서 자동화 뿐만 아니라 UI에서 직접 API 테스트도 가능하다. 개발환경 Spring Boot Maven Java 8 Swagger 2.9.2 Swagger 의존성 추가 - pom.xml io.springfox springfox-swagger2 2.9.2 io.springfox springfox-swagg..
[Error] org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileUploadController': 경로 에러 Controller 내에 있는 DAO를 불러오지 못 했다고 한다. root-context.xml 을 확인하니 context:component-scan 선언이 되어있지 않음. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'fileUploadController': Unsatisfied dependency expressed through field 'fileUploadDAO'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com...
[Error] The declared package "" does not match the expected package - 패키지 미참조 에러 Class에 해당 패키지 미참조 시 발생함. The declared package "" does not match the expected package Class 최상단에 해당 패키지 참조 해주면 됨. package com.sample.controller;
[Error] log4j2 - ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console. Set system property 'log4j2.debug' to show Log4j2 internal initialization logging. https://devel-log.tistory.com/27 [Error] tomcat server , log4j error - java.lang.ClassNotFoundException: org.springframework.web.util.Log4jConfigListener 1. 멀쩡하게 하다가 갑자기 에러 발생. log4j:WARN No appenders could be found for logger (org.springframework.web.context.ContextLoader). log4j:WARN Please initialize the log4j system pr.. devel-log.tistory.com 직전 에러 때문에 log4j2를 추가하였는데, 실행하고 보니 에러 발생. SLF4J: C..
[Error]Failed to load resource: the server responded with a status of 404 () Failed to load resource: the server responded with a status of 404 () 경로 틀려서 나는 에러