Программисты JAVA общаются здесь
Anonymous
JAVA 17 SPRING BOOT 3.4.1 Jakarta XML Binding-API не найден в пути к модулю или пути к классам [дубликат]
Сообщение
Anonymous » 21 янв 2025, 15:39
Я пытаюсь создать XML-файл на основе возврата API, возврата API. Я хочу создать файл, но он выдает эту ошибку.
ОШИБКА
Код: Выделить всё
Jakarta XML Binding-API has not been found on module path or classpath. processing failed: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.
Код: Выделить всё
@GetMapping(value = "/metalsTest")
public Object retornarMetalsTest() throws JAXBException, IOException {
Gson gson = new Gson();
String dados = cotacaoClient.testeCards();
CardsResponse cardsResponse = new CardsResponse();
cardsResponse = gson.fromJson(dados, CardsResponse.class);
JAXBContext context = JAXBContext.newInstance(CardsResponse.class);
Marshaller marshaller = context.createMarshaller();
marshaller.marshal(cardsResponse, new FileWriter("C:\\Users\\Jessyca\\Desktop\\files\\cards.xml"));
System.out.println(cardsResponse);
return cardsResponse;
}
Код: Выделить всё
package com.jessycadev.ApiCotacao.Client;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class CardsResponse {
private String success;
private String deck_id;
private String remaining;
private String shuffled;
public CardsResponse() {
}
public CardsResponse(String success, String deck_id, String remaining, String shuffled) {
this.success = success;
this.deck_id = deck_id;
this.remaining = remaining;
this.shuffled = shuffled;
}
public String getSuccess() {
return success;
}
public void setSuccess(String success) {
this.success = success;
}
public String getDeck_id() {
return deck_id;
}
public void setDeck_id(String deck_id) {
this.deck_id = deck_id;
}
public String getRemaining() {
return remaining;
}
public void setRemaining(String remaining) {
this.remaining = remaining;
}
public String getShuffled() {
return shuffled;
}
public void setShuffled(String shuffled) {
this.shuffled = shuffled;
}
}
xml-файл с информацией об объекте
Подробнее здесь:
https://stackoverflow.com/questions/793 ... n-module-p
1737463183
Anonymous
Я пытаюсь создать XML-файл на основе возврата API, возврата API. Я хочу создать файл, но он выдает эту ошибку. ОШИБКА [code]Jakarta XML Binding-API has not been found on module path or classpath. processing failed: javax.xml.bind.JAXBException: Implementation of JAXB-API has not been found on module path or classpath.[/code] [code]@GetMapping(value = "/metalsTest") public Object retornarMetalsTest() throws JAXBException, IOException { Gson gson = new Gson(); String dados = cotacaoClient.testeCards(); CardsResponse cardsResponse = new CardsResponse(); cardsResponse = gson.fromJson(dados, CardsResponse.class); JAXBContext context = JAXBContext.newInstance(CardsResponse.class); Marshaller marshaller = context.createMarshaller(); marshaller.marshal(cardsResponse, new FileWriter("C:\\Users\\Jessyca\\Desktop\\files\\cards.xml")); System.out.println(cardsResponse); return cardsResponse; } [/code] [code]package com.jessycadev.ApiCotacao.Client; import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement public class CardsResponse { private String success; private String deck_id; private String remaining; private String shuffled; public CardsResponse() { } public CardsResponse(String success, String deck_id, String remaining, String shuffled) { this.success = success; this.deck_id = deck_id; this.remaining = remaining; this.shuffled = shuffled; } public String getSuccess() { return success; } public void setSuccess(String success) { this.success = success; } public String getDeck_id() { return deck_id; } public void setDeck_id(String deck_id) { this.deck_id = deck_id; } public String getRemaining() { return remaining; } public void setRemaining(String remaining) { this.remaining = remaining; } public String getShuffled() { return shuffled; } public void setShuffled(String shuffled) { this.shuffled = shuffled; } } [/code] xml-файл с информацией об объекте Подробнее здесь: [url]https://stackoverflow.com/questions/79374446/java-17-spring-boot-3-4-1-jakarta-xml-binding-api-has-not-been-found-on-module-p[/url]