감자튀김 공장🍟

[Spring] java.lang.UnsupportedClassVersionError 본문

JAVA/Spring

[Spring] java.lang.UnsupportedClassVersionError

Potato potage 2022. 7. 1. 21:23
반응형
Exception in thread "main" java.lang.UnsupportedClassVersionError: hello/hellospring/HelloSpringApplication has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0

인프런에서 Spring 강의 들으면서 빌드 도중 이런 에러가 떴다.

Error를 찾아보니까 프로젝트 파일은 55.0 버전으로 컴파일 되어 있지만 현재 컴파일러 버전이 52.0이라 로딩이 불가하다는 에러였다.

 

그래서 일단 구글링으로 해결하는 방법들을 봤다.

 

 

대충 요약하자면 (intelliJ 기준)

File > Project Structrure에서 Project SDK 버전과 / Preferences 에서 Java Compiler 버전을 원래 버전과 맞춰주면 된다.

 


 

하지만 나는 이미 같은 버전으로 다 맞춰져 있었기 때문에 java -version으로 버전부터 확인해 봤더니

> java -version
java version "1.8.0_271"
Java(TM) SE Runtime Environment (build 1.8.0_271-b09)
Java HotSpot(TM) 64-Bit Server VM (build 25.271-b09, mixed mode)

 

이렇게 떴다.

 

프로젝트 SDK와 compiler는 다 Java SE 11로 맞춰놓은 상태였지만 컴퓨터에 설치된 버전과 다르기 때문에 오류가 났었던 것이다.

 

 


그래서 해결 방법은 간단하다!

제어판 > 프로그램 및 기능에서 Java 8 Update와 Java SE Development Kit 8 Update 를 삭제하면 된다.

 

Java 8을 싹 지우고 다시 java -version을 해봤더니 이렇게 떴다!

> java -version
java version "11.0.10" 2021-01-19 LTS
Java(TM) SE Runtime Environment 18.9 (build 11.0.10+8-LTS-162)
Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.10+8-LTS-162, mixed mode)

 

그리고 진행하던 스프링 프로젝트도 빌드해봤더니 잘 돌아간다😁

반응형

'JAVA > Spring' 카테고리의 다른 글

[Spring] MVC 패턴 알아보기  (0) 2022.04.19
[Spring] Aspect Oriented Programming (AOP)이란?  (0) 2022.04.18
[Spring] Dependency Injection(DI)란?  (0) 2022.04.17
[Spring] Spring 개요  (0) 2022.04.15
Comments