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

23.03.24 11:36 작성 23.03.24 11:55 수정 조회수 714

0

java11, springboot2.7.1로 프로젝트 진행했던 프로젝트를 열어 실행하니 에러가 발생합니다.

해결하지 못하여 질문드립니다!

  • 발생에러

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()'.
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
  • 시도

    java JDK 버전 확인, 빌드 자동 실행 설정 등.. 구글링해서 찾아봤으나 해결하지 못했습니다ㅠㅠ

  • 검색해보면 jaxb-api:. 를 기준으로 나오는데, 제 에러는 jsxb-api 입니다 이 둘의 차이는 무엇인가요?

답변 1

답변을 작성해보세요.

0

인프런 AI 인턴님의 프로필

인프런 AI 인턴

2023.05.24

안녕하세요, 인프런 AI 인턴이에요.

결과적으로는 해당 라이브러리가 누락된 것으로 보입니다.
이에 대한 해결책으로는 Maven이나 Gradle의 의존성 설정에서 javax.xml.bind:jaxb-api 대신 javax.xml.bind:jaxb-runtime을 사용하는 것입니다. jsxb-api 와 jaxb-runtime 모두 JAXB (Java Architecture for XML Binding) API 구현을 제공하지만 최신 버전에서는 jaxb-runtime 을 사용하는 것이 권장됩니다.

또한, Java11에서는 javax.xml.bind API가 모듈화되어 별도로 사용자가 모듈을 추가해야합니다. 모듈 추가는 다음과 같은 방법으로 수행할 수 있습니다.
module-info.java 파일을 만들고 해당 모듈의 종속성 설정을 추가한 다음 Gradle 또는 Maven의 의존성 설정에서 해당 모듈 이름을 추가합니다.

참고로 JAXB 2.x는 자바 9부터 포함되지 않으므로 Java 9 이상 사용자는 별도로 종속성을 추가해야합니다.

혹시나 Gradle이나 Maven 의존성 등록을 확인했는데도 해결되지 않는다면, Gradle 캐시를 삭제하고 다시 실행해보세요. Gradle 캐시는 프로젝트 디렉토리에서 ./gradle/caches 경로에 있습니다.

마지막으로, “jaxb-api”와 “jsxb-api”의 차이는 없습니다. 스펠링이 다른 것 뿐이고 같은 라이브러리를 제공합니다.

도움이 되었길 바랍니다.