Spring

[Spring] 인텔리제이 swagger 에러 해결

P.젤리비 2022. 8. 23.
반응형

스프링 이니셜라이져로 프로젝트를 생성하여 인텔리제이에서 사용하면 참 많은 오류가 발생한다.;;

그 중 새로운 의존성을 주입했을때 발생하는 문제인데.

 

swagger를 의존성 주입했을때 잡다한 경고들이 많이 발생하였다.

 

JDK버젼 일치

settings > Build, Execution, Deployment > Build Tools > Gradle의 Gradle JVM,

settings > Build, Execution, Deployment > compiler > Java Compiler의 per-module bytecode version,

Project Structure > project settings > project의 SDK

이 셋의 버젼을 맞춰준다.

가끔 여기서도 오류남.

 

Build 변경

settings > Build, Execution, Deployment > Build Tools > Gradle

build and run using, run tests using을 Gradle에서 IntelliJ IDEA로 변경한다.

무료버젼을 써서인지 이런데서도 오류가 난다. 유료버젼은 안난다고 하더라;;

 

그 후를 살펴보자.

 

Deprecated Gradle features were used in this build, making it incompatible with Gradle x.x

File > Settings > Build, Execution, Deployment > Compiler > Java Compiler > Additional command line parameters

아래 명령을 넣고 저장한다.

--warning-mode=all --stacktrace

사실 이 에러는 그냥 무시해도 전혀 실행에 지장이 없다고 한다. 후에 이것 때문에 또 다른 오류가 발생한다.

당장에 거슬린다면 사용하되. 경고뜨면 지우면 된다.

 

process finished with exit code 1

이건 특별한 오류메시지도 없이 Run이 되지않는다.

본래 리턴0로 종료되어야 정상인데. 1로 종료된다는 의미다.

Main에 try-catch를 사용하여 오류를 검출해낸다.

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class RestaurantApplication {
	public static void main(String[] args) {
		try {
			SpringApplication.run(RestaurantApplication.class, args);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

 

org.springframework.context.applicationcontextexception: failed to start bean 'documentationpluginsbootstrapper'; nested exception is java.lang.nullpointerexception

드디어 나왔다. 갖가지 에러를 발생시키며 개고생을 하게 만든 에러이다.

이거만 해결하면 정상 작동하게 된다.

이 에러는 swagger뿐만 아니라 의존성 주입시 버젼차이로 인해 발생하는 여러 문제를 해결해줄것이다.

 

Spring boot 2.6버전 이후에 spring.mvc.pathmatch.matching-strategy 값이 ant_apth_matcher에서 path_pattern_parser로 변경되면서 몇몇 라이브러리에서 오류가 발생하고 있다.

application.properties 파일에서 한 줄을 추가한다.

spring.mvc.pathmatch.matching-strategy=ant_path_matcher

 

캐시 지우기

File > Invalidate Caches를 사용하면 캐시를 지우고 다시 시작할 수 있다.

캐시가 남아서 계속해서 문제를 발생시키는 것일 수 있으니.

밑져야 본전! 한번 해보도록 하자.

반응형

댓글

💲 추천 글