천리길도 한걸음부터

View 환경설정 본문

김영한 강의 정리📑

View 환경설정

밤연양갱 2025. 3. 8. 04:05

어제 강의 듣다 잠..ㅋㅋㅋㅋㅋㅋ ㅠㅠ

아닠... ㅠ ㅠ강의 시점이랑 지금이랑 아무리 달라도.. 에러 해결 하는데ㅋㅋㅋ 시간 걸리는거 슬프다..

나의 실력이여.. 어쨌든 해결은 되서 다행.. ㅎ ㅏ ㅎ ㅏ

엊그제는 분명 17에서 23으로 바꿨는데, 뭔일..


Spring 홈페이지 - Guide
들어가서, api, thymeleaf 이런식으로 치면, 어떻게 실행하는지 나옴.
이론이 감이 안올때, 이렇게 실행해보고 공부하는 것도 좋음.
----------------------------------------------------------------------------------------------
-

[에러]
A problem occurred configuring root project 'jpashop'.
> Could not resolve all artifacts for configuration 'classpath'.
   > Could not resolve org.springframework.boot:spring-boot-gradle-plugin:3.4.3.
     Required by:
         root project : > org.springframework.boot:org.springframework.boot.gradle.plugin:3.4.3
      > Dependency requires at least JVM runtime version 17. This build uses a Java 11 JVM.

* Try:
> Run this build using a Java 17 or newer JVM.
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.12.1/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 130ms



[해결]
Java 23을 제거하고, Java 17을 설치한 뒤, 환경변수 설정 해줌.
gradle과 플러그인들이 호환되지 않아서..........생기는 문제라고 함..

------- 허허허.. 에러 자세히 보기 위해 이 명령어도 써보았....
./gradlew bootRun --stacktrace

스택 추적 (stack trace, stack backtrace[1] 또는 stack traceback[2])은 프로그램 실행 중 특정한 시점에서의 스택 프레임에 대한 리포트이다. 프로그램 실행 중 메모리는 보통 두 곳에 동적으로 할당되는데, 스택과 힙이 그것이다. 메모리는 이름에서 보이듯이 스택에서는 인접하여 할당되지만 힙은 그렇지 않다. 스택은 또한 프로그래밍 구조로도 여겨지며 프로그램의 런타임 스택으로 불린다. 기술적으로 메모리 블록이 스택에 할당되면, 이것은 그 이전에 할당된 블록같이 쉽게 제거되지 않는다. 프로그램에서 함수가 호출될 때마다 메모리 블록은 활성 레코드 (activation record)라고 불리는 런타임 스택의 위에 할당된다. 높은 수준에서는, 활성 레코드가 함수의 파라미터와 내부에 선언된 지역변수를 위해서 메모리를 할당한다.

프로그래머들은 보통 상호적인 사후 분석 디버깅에서 스택 추적을 사용한다. 최종 사용자들은 화면의 오류 메시지를 통해 스택 추적을 보게 되며 이것을 보고 프로그래머에게 리포트를 보낼 수 있다.

스택 추적은 호출된 중첩 함수의 순서를 스택 추적이 생성된 지점까지 추적할 수 있게 한다. 사후 분석 시나리오에서 이것은 실패가 발생한 함수까지 확장된다. 형재 함수 호출은 스택 추적에서 볼 수 없다.

[에러]
Exception in thread "main" java.lang.UnsupportedClassVersionError: jpabook/jpashop/JpashopApplicationTests has been compiled by a more recent version of the Java Runtime (class file version 67.0), this version of the Java Runtime only recognizes class file versions up to 61.0
at java.base/java.lang.ClassLoader.defineClass1(Native Method)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:150)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:862)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:760)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:681)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:639)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:375)
at com.intellij.junit5.JUnit5TestRunnerUtil.loadMethodByReflection(JUnit5TestRunnerUtil.java:126)
at com.intellij.junit5.JUnit5TestRunnerUtil.buildRequest(JUnit5TestRunnerUtil.java:102)
at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:43)
at cohttp://m.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
at cohttp://m.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
at cohttp://m.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
at cohttp://m.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232)
at cohttp://m.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55)

Process finished with exit code 1

[원인]
현재 쓰는 Java 버전이 더 낮음. 이전에 컴파일된 버전은 23인데, 17로 바꾸어서 실행해서 일치하지 않는 현상.
class file version 67.0 → Java 23 (JDK 23)로 컴파일됨!
this version of the Java Runtime only recognizes class file versions up to 61.0 → 현재 실행 중인 JDK가 Java 17 (JDK 17) 이하!
즉, 실행하는 JDK와 프로젝트 컴파일된 JDK 버전이 다름!


[해결]
1. JDK 버전 일치시키기
-> 현재 JDK 버전 확인 (IntelliJ 설정)

 확인... 확인할데 엄청 많더라....

 

Settings > gradle
File > Project Structure > Project

Project SDK → Java 17인지 확인
File > Settings > Build, Execution, Deployment > Compiler > Java Compiler

Run > Edit Configurations
Use classpath of module → 올바른 JDK 모듈 선택!

2. Gradle 빌드 설정 확인
build.gradle 파일에서

java {
    sourceCompatibility = JavaVersion.VERSION_17
    targetCompatibility = JavaVersion.VERSION_17
}

-> JDK 17을 사용하려면 프로젝트 전체를 JDK 17로 맞추기

spring-boot-devtools 를 쓰면, html파일을 컴파일만 해주면, 서버 재시작 없이 View 파일 변경 가능!