RESTful web service based on JAX-WS returns xml document generated through JAXB annotations

A RESTful web service written based on JAX-WS that returns xml documents. This xml document can be generated based on JAXB annotations, simplifying xml generation. In order to use the dependent libraries, you can add the following dependencies in the pom.xml file of the maven project: <dependency> <groupId>jakarta.xml.ws</groupId> <artifactId>jakarta.xml.ws-api</artifactId> <version>4.0.0</version> </dependency> <dependency> <groupId>com.sun.xml.ws</groupId> <artifactId>jaxws-rt</artifactId> <version>4.0.0</version> […]

java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException hibernate-validator

Scenario: add in the project implementation ‘org.hibernate:hibernate-validator:5.1.1.Final’ Add request parameter validation: entity: @Data @ApiModel(value = “Client Details”) public class ClientDetailsDTO { @NotEmpty @ApiModelProperty(“client id”) private String clientId; @ApiModelProperty(“Client key”) private String clientSecret; } @PostMapping(“/authClient/create”) @ApiOperation(value = “Add client configuration data”, httpMethod = “POST”, response = Object.class) public void createCodeType(@Validated @RequestBody ClientDetailsDTO details) { clientService.create(details); } […]

XML parsing in Java (JAXB mode)

JAXB Introduction to JAXB ? JAXB (Java Architecture for XML Binding) is part of the Java API, which provides a way to map Java classes to XML structures, and can also convert XML structures into instances of Java classes. It is a way to simplify the interaction between Java and XML, and Java classes can […]

JAXB – conversion of xml and object

When interacting with a third party, the other party requires data transmission in xml format. If you splicing and parsing the message yourself, you can indeed achieve the effect, but this is not only not elegant but also very cumbersome, time-consuming and labor-intensive. Searching for information found that there is support for xml in the […]

[Solved] [Effective real test] Solve Jwt error: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException

Solving Jwt error: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException 1. Fault description I got this error today when using Hibernate in a JDK 17 environment. The error log is as follows: 2. Failure cause analysis JAXB API is the API of java EE, so this Jar package is no longer included in java SE 17. The concept of modules […]

[Solved] Solutions for java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException

Cause of the problem: This error occurs when using eclipse to package the springboot project, and then running the cmd command java -jar xxx.jar: java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException Solution: Add the following dependencies in pom.xml. <dependency> <groupId>javax.xml.bind</groupId> <artifactId>jaxb-api</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-impl</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>com.sun.xml.bind</groupId> <artifactId>jaxb-core</artifactId> <version>2.3.0</version> </dependency> <dependency> <groupId>javax.activation</groupId> <artifactId>activation</artifactId> <version>1.1.1</version> </dependency>

[Solved] JAXB implements Java object and XML conversion

The webService interface needs to use the conversion between XML and objects. Java can realize the mutual conversion between xml and objects through JAXB and XStream. The following uses JAXB to realize the conversion between xml and objects. 1. Define the DTO class to be converted to XML import javax.xml.bind.annotation.*; /** * @author * @Description […]