Could not find javax.xml.bind:jsxb-api:.

may_yun·2023년 3월 24일
0

인텔리제이 빨간줄..

프로젝트 리팩토링을 위해 서버리스 배포를 시도하기위해 몇 달전 개인 플젝으로 진행했던 로또 프로젝트를 열었더니 잘 되던 프로젝트가 전부 빨간줄이 따다당..!!!!

발생한 에러

Could not find javax.xml.bind:jsxb-api:.

Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find javax.xml.bind:jsxb-api:.
     Required by:
         project :

Possible solution:
 - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html

도대체 이게 뭘까 처음에 Execution failed for task ':compileJava'. 키워드로 검색해 봤더니 프로젝트 jdk 버전문제 혹은 자바 경로 설정때문이라고 한다

나는 JDK 버전을 확인해보니 모두 java11로 되어있었고,
다시 Could not find javax.xml.bind:jsxb-api:. 키워드로 검색

testImplementation 'com.h2database:h2:1.4.200'

에러를 다시 한번 봤다

11:46:16 AM: Executing ':RandomApplication.main()'...

> Task :compileJava FAILED

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

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.4.1/userguide/command_line_interface.html#sec:command_line_warnings
1 actionable task: 1 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
   > Could not find javax.xml.bind:jsxb-api:.
     Required by:
         project :

* Try:
> 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 652ms
11:46:16 AM: Execution finished ':RandomApplication.main()'.

해결

: Build and run using, Run tests using을 Gradle에서 IntelliJ로 변경하고 실행했더니 정상 실행됐다!
Gradle로 실행하라고하는 글들이 많은데 왜 해당 케이스에서는 IntelliJ로 실행했을 때 정상 작동하는지 모르겠다 아마 Gradle 버전 때문인가?


서버리스 AWS Lambda 빌드시 또 다시 만난 녀석...

그래도 이번에는 Gradle Sync issues라는 키워드를 받았다

검색해서 찾아보니,
자주 발생하는 오류는 아니지만 예전 소스를 import 하거나 Android studio version 을 update 하면서 종종 아래와 같은 Gradle sync 오류가 발생한다고 한다

이때는 Gradle 버전을 업데이트 해야한다고 한다
위의 해결 방법과 어느정도 연관이 있어보인다.
Gradle로 실행하지 않고 인텔리제이로 실행했을 때 정상적으로 실행됐기 때문이다

  • 변경 전
  1. 인텔리제이 프로젝트 내부 terminal에서 Gradle 버전 확인
 ./gradlew -v

  1. gradle 버전 변경
    해당 프로젝트 터미널에서 아래 명령어 사용
./gradlew wrapper --gradle-version {7.5.1}변경할 버전 넣기

📌 그래들 빌드시 info, debug 찍어보는것을 생활화 하자!@!

gradle build --info
gradle build --debug
gradle --warning-mode all

AWS Lambda 배포 빌드시 발생한 에러

sudo ./gradlew buildZip 빌드 실패

  • zip파일을 만들기 위해서 sudo ./gradlew buildZip 명령어를 실행했을 때 아래와 같이 빌드를 실패한다.

해결

  • build.gradle 라이브러리 추가

만약 자바 프로젝트를 빌드하는 도중 Could not find javax.xml.bind:jsxb-api: 에러가 발생한다면, 이는 Java 11에서 Java EE 모듈, 특히 JAXB API를 제거했기 때문일 수 있습니다. 이로 인해 JAXB API에 의존하는 일부 라이브러리는 Java 11에서 빌드나 실행이 실패할 수 있습니다.

이러한 에러를 해결하려면, 프로젝트의 빌드 구성 파일(e.g. Maven의 pom.xml 또는 Gradle의 build.gradle)에 다음 종속성을 추가하면 됩니다

	implementation 'javax.xml.bind:jaxb-api:2.3.1'

참고 링크

profile
개발 일지

0개의 댓글