inflearn logo
강의

강의

N
챌린지

챌린지

멘토링

멘토링

N
클립

클립

로드맵

로드맵

지식공유

실전! 스프링 부트와 JPA 활용1 - 웹 애플리케이션 개발

JPA와 DB 설정, 동작확인

jar build 동작 확인을 위한 Window cmd 이용 중 Build failed with an exception 오류

543

박진재

작성한 질문수 8

0

질문 시에는 위 내용은 삭제하고 다음 내용을 남겨주세요.
=========================================
[질문 템플릿]
1. 강의 내용과 관련된 질문인가요? (예/아니오)
2. 인프런의 질문 게시판과 자주 하는 질문에 없는 내용인가요? (예/아니오)
3. 질문 잘하기 메뉴얼을 읽어보셨나요? (예/아니오)

[질문 내용]
H2 database Ctrl C 후
gradlew clean build 실행 시 아래와 같이 화면이 나타납니다.

이전에 시행했을땐 이런 오류가 떴습니다.
(base) C:\study\jpashop\jpashop>gradlew clean build

Welcome to Gradle 8.7!

Here are the highlights of this release:

For more details see https://docs.gradle.org/8.7/release-notes.html

Starting a Gradle Daemon (subsequent builds will be faster)

Task :compileJava FAILED

FAILURE: Build failed with an exception.

error: invalid source release: 21

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.

BUILD FAILED in 8s 2 actionable tasks: 2 executed

Gradle 8.7같은 경우 Java 22와 호환이 되어있는것 같은데 Java21로 설정하고 프로젝트를 진행 했을 때 어떻게 처리해야하는지 궁금합니다.

java spring 웹앱 spring-boot jpa

답변 1

0

인프런 AI 인턴

안녕하세요, 인프런 AI 인턴입니다.

박진재님의 jar build 관련 문제와 유사한 경우를 살펴본 결과, 질문자님이 겪고 계시는 오류는 “invalid source release: 21”로 컴파일 중 Java 소스 버전에 관련된 문제로 보입니다. 이번 경우, Gradle이 Java 22를 지원하면서 Java 21로 설정하여 발생한 문제로 추측됩니다. 이와 유사한 상황이나 문제를 해결한 기존 답변을 우선 추천드립니다.

  1. gradlew clean build 오류
    • 이 답변에서는 Java 버전과 Gradle 설정이 일치하지 않아 발생한 문제를 다루고 있습니다. JDK 버전과 build.gradle 파일 내의 sourceCompatibility 설정이 일치하는지 확인해야 합니다. 질문 내용과 비슷하게 invalid source release 에러가 발생한 상황이며, JDK를 새로 설치하거나 올바른 버전으로 설정 변경하는 것으로 해결되었습니다.

Java 기반 프로젝트에서 Gradle 또는 Maven과 같은 빌드 도구를 사용할 때, 올바른 Java 버전 설정은 매우 중요합니다. sourceCompatibility는 프로젝트가 사용하는 Java 소스 코드의 버전을 Gradle에 알려주어야 할 때 사용됩니다. JDK 버전과 이 설정이 일치하지 않을 때, 컴파일 에러가 발생할 수 있습니다.

현재 문제를 해결하기 위해서는 다음과 같은 방법을 제안드립니다:
1. JDK 버전 확인: 프로젝트에 맞는 JDK 버전이 설치되어 있는지 확인하세요.
2. 환경변수 확인: JAVA_HOME 환경변수가 올바른 JDK 경로로 설정되어 있는지 검토하세요.
3. Gradle 설정 확인: build.gradle 파일 내 sourceCompatibility 값을 현재 설치된 JDK 버전과 일치하게 수정하세요.

추가적으로 설정 후 IDE나 명령 프롬프트를 재시작하여 변경 사항을 적용하는 것을 잊지 마세요.

저는 질문자님의 이해를 돕고자 지식공유자님의 기존 답변을 참고하여 유사한 답변 링크를 추천해드리고 있습니다.
현재 베타 기능으로 답변이 만족스럽지 않을 수 있는 점 양해 부탁드립니다. 🙏
추가적으로 궁금한 점이 있으시면, 이어서 질문해 주세요. 곧 지식공유자께서 답변해 주실 것입니다.

0

박진재

확인해보니까 Gradle 설정은 21로 해두었지만 jdk-17.0.8.101-hotspot이 기본 환경 변수로 설정되어있고 JDK21이 실제로 설치가 안되었을때는 직접설치하고 환경변수경로를 JDK21 경로로 바꿔줘야하는거죠?

0

David

안녕하세요. 박진재님, 공식 서포터즈 David입니다.

네, 맞습니다.

감사합니다.

0

박진재


저 오류 무시 후 build/libs 에 java -jar 파일도 실행해봤는데 아래와 같이 오류가떠서 이럴땐 어떻게 해야하는지 궁금합니다.

Error: -jar requires jar file specification

Usage: java [options] <mainclass> [args...]

(to execute a class)

or java [options] -jar <jarfile> [args...]

(to execute a jar file)

or java [options] -m <module>[/<mainclass>] [args...]

java [options] --module <module>[/<mainclass>] [args...]

(to execute the main class in a module)

or java [options] <sourcefile> [args]

(to execute a single source-file program)

Arguments following the main class, source file, -jar <jarfile>,

-m or --module <module>/<mainclass> are passed as the arguments to

main class.

where options include:

-cp <class search path of directories and zip/jar files>

-classpath <class search path of directories and zip/jar files>

--class-path <class search path of directories and zip/jar files>

A ; separated list of directories, JAR archives,

and ZIP archives to search for class files.

-p <module path>

--module-path <module path>...

A ; separated list of elements, each element is a file path

to a module or a directory containing modules. Each module is either

a modular JAR or an exploded-module directory.

--upgrade-module-path <module path>...

A ; separated list of elements, each element is a file path

to a module or a directory containing modules to replace

upgradeable modules in the runtime image. Each module is either

a modular JAR or an exploded-module directory.

--add-modules <module name>[,<module name>...]

root modules to resolve in addition to the initial module.

<module name> can also be ALL-DEFAULT, ALL-SYSTEM,

ALL-MODULE-PATH.

--enable-native-access <module name>[,<module name>...]

modules that are permitted to perform restricted native operations.

<module name> can also be ALL-UNNAMED.

--list-modules

list observable modules and exit

-d <module name>

--describe-module <module name>

describe a module and exit

--dry-run create VM and load main class but do not execute main method.

The --dry-run option may be useful for validating the

command-line options such as the module system configuration.

--validate-modules

validate all modules and exit

The --validate-modules option may be useful for finding

conflicts and other errors with modules on the module path.

-D<name>=<value>

set a system property

-verbose:[class|module|gc|jni]

enable verbose output for the given subsystem

-version print product version to the error stream and exit

--version print product version to the output stream and exit

-showversion print product version to the error stream and continue

--show-version

print product version to the output stream and continue

--show-module-resolution

show module resolution output during startup

-? -h -help

print this help message to the error stream

--help print this help message to the output stream

-X print help on extra options to the error stream

--help-extra print help on extra options to the output stream

-ea[:<packagename>...|:<classname>]

-enableassertions[:<packagename>...|:<classname>]

enable assertions with specified granularity

-da[:<packagename>...|:<classname>]

-disableassertions[:<packagename>...|:<classname>]

disable assertions with specified granularity

-esa | -enablesystemassertions

enable system assertions

-dsa | -disablesystemassertions

disable system assertions

-agentlib:<libname>[=<options>]

load native agent library <libname>, e.g. -agentlib:jdwp

see also -agentlib:jdwp=help

-agentpath:<pathname>[=<options>]

load native agent library by full pathname

-javaagent:<jarpath>[=<options>]

load Java programming language agent, see java.lang.instrument

-splash:<imagepath>

show splash screen with specified image

HiDPI scaled images are automatically supported and used

if available. The unscaled image filename, e.g. image.ext,

should always be passed as the argument to the -splash option.

The most appropriate scaled image provided will be picked up

automatically.

See the SplashScreen API documentation for more information

@argument files

one or more argument files containing options

--disable-@files

prevent further argument file expansion

--enable-preview

allow classes to depend on preview features of this release

To specify an argument for a long option, you can use --<name>=<value> or

--<name> <value>.

0

David

gradle 버전을 8.5로 낮춘 뒤 다시 시도해 보시겠어요?
https://www.inflearn.com/questions/1251256/comment/336001

sdk 설정 오류

0

53

2

오탈자 - @Transactional

0

56

1

src/test/resources 테스트 경로 문제

0

50

1

상품 등록후 H2 db 출력 순서 바꿀 수 있나요?

0

64

1

MemberRepositoryTest 실행오류

0

81

1

boot 4.x >>> trasasction rolled back log & p6spy(영한님, 수업 자료 업데이트 해주시면 감사하겠습니다!!)

1

183

2

강의 마지막 QueryDSL 사용 부분 질문있습니다

1

142

2

클라이언트에서 isbn과 author 수정 요청을 한 경우에 대해 질문드립니다.

0

51

1

도메인 모델 패턴 vs 트랜잭션 스크립트 패턴

0

71

1

기본 생성자

0

60

1

h2 DB 연결시 jdbc url 변경 이유가 궁금합니다.

0

102

1

멤버서비스테스트 부분에서 막힙니다.

0

165

4

실무에서도 EntityManager를 이용해서 많이 작업하는 편일까요?

0

116

1

초반에 h2 다운로드 과정 꼭 필요한가요?

0

120

2

자신 필드에도 get으로 접근하는 이유가 있을까요?

0

114

1

24분 27초 연관관계 편의 메서드 위치

0

113

1

단건 주문만 가능하게 한건 의도한 부분이신가요?

0

109

2

빌드 툴, Gradle

0

59

1

h2연결은 된 것 같은데 엔티티 테이블까지 작성 후 확인해보아도 테이블이 안보입니다

0

77

2

Repository에서 EntityManager 주입 방식 차이

0

90

1

롬복과 사용자 정의 setter 메서드

0

72

1

주문 목록 조회 fetch join 질문드립니다

0

82

1

dirty checking 질문드립니다.

0

83

1

동시성 관련 질문입니다

0

75

1