SpringBoot 3.2.1 with Java 17

This commit is contained in:
ale 2024-01-14 22:32:29 +01:00
parent b783830058
commit f5539d4f5f
10 changed files with 29 additions and 437 deletions

View File

@ -1,4 +1,4 @@
FROM openjdk:11-jdk
FROM openjdk:17-jdk
COPY . /ws
WORKDIR /ws
ENTRYPOINT ["./mvnw", "spring-boot:run", "-f", "pom.xml"]
ENTRYPOINT ["./mvnw", "spring-boot:run", "-f", "pom.xml"]

View File

@ -1,4 +1,4 @@
# How construct `WebServices` with SpringBoot 2.1.5 RELEASE (modern way)
# How construct `WebServices` with SpringBoot 3.2.1 and Java 17 (modern way)
## Run
```
@ -14,4 +14,4 @@ curl -H "content-type: text/xml" -d @request.xml http://localhost:8080/ws
```
docker build --rm -t ws .
docker run -ti --rm --name ws --network host ws
```
```

66
pom.xml
View File

@ -6,7 +6,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.5.RELEASE</version>
<version>3.2.1</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.manalejandro</groupId>
@ -17,7 +17,7 @@
<description>Demo project for Spring Boot with Web Services</description>
<properties>
<java.version>11</java.version>
<java.version>17</java.version>
</properties>
<dependencies>
@ -40,28 +40,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- https://github.com/eclipse-ee4j/jaxb-ri/issues/1235 -->
<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.activation/activation -->
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.glassfish.jaxb/jaxb-runtime -->
<dependency>
<groupId>org.glassfish.jaxb</groupId>
<artifactId>jaxb-runtime</artifactId>
</dependency>
</dependencies>
<build>
@ -71,26 +49,26 @@
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- Plugin for generate WS classes -->
<!-- <plugin> -->
<!-- <groupId>org.codehaus.mojo</groupId> -->
<!-- <artifactId>jaxb2-maven-plugin</artifactId> -->
<!-- <version>2.4</version> -->
<!-- <executions> -->
<!-- <execution> -->
<!-- <goals> -->
<!-- <goal>xjc</goal> -->
<!-- </goals> -->
<!-- </execution> -->
<!-- </executions> -->
<!-- <configuration> -->
<!-- <sources> -->
<!-- <source>src/main/resources/person.xsd</source> -->
<!-- </sources> -->
<!-- <packageName>com.manalejandro.ws.model</packageName> -->
<!-- <outputDirectory>${project.basedir}/src/main/java</outputDirectory> -->
<!-- <clearOutputDir>false</clearOutputDir> -->
<!-- </configuration> -->
<!-- </plugin> -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxb2-maven-plugin</artifactId>
<version>3.1.0</version>
<executions>
<execution>
<goals>
<goal>xjc</goal>
</goals>
</execution>
</executions>
<configuration>
<sources>
<source>src/main/resources/person.xsd</source>
</sources>
<packageName>com.manalejandro.ws.model</packageName>
<outputDirectory>${project.basedir}/src/main/java</outputDirectory>
<clearOutputDir>false</clearOutputDir>
</configuration>
</plugin>
</plugins>
</build>

View File

@ -1,26 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<bindings version="2.1" xmlns="http://java.sun.com/xml/ns/jaxb">
<!--
Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
Generado el: 2019.05.19 a las 11:13:06 PM CEST
-->
<bindings scd="x-schema::tns" xmlns:tns="http://www.manalejandro.com/person">
<schemaBindings map="false">
<package name="com.manalejandro.ws.model"/>
</schemaBindings>
<bindings scd="tns:getPersonRequest">
<class ref="com.manalejandro.ws.model.GetPersonRequest"/>
</bindings>
<bindings scd="tns:getPersonResponse">
<class ref="com.manalejandro.ws.model.GetPersonResponse"/>
</bindings>
<bindings scd="~tns:Person">
<class ref="com.manalejandro.ws.model.Person"/>
</bindings>
</bindings>
</bindings>

View File

@ -1,71 +0,0 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
//
package com.manalejandro.ws.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Clase Java para anonymous complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* &lt;complexType&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"name"
})
@XmlRootElement(name = "getPersonRequest")
public class GetPersonRequest {
@XmlElement(required = true)
protected String name;
/**
* Obtiene el valor de la propiedad name.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Define el valor de la propiedad name.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
}

View File

@ -1,71 +0,0 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
//
package com.manalejandro.ws.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Clase Java para anonymous complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* &lt;complexType&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="Person" type="{http://www.manalejandro.com/person}Person"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"person"
})
@XmlRootElement(name = "getPersonResponse")
public class GetPersonResponse {
@XmlElement(name = "Person", required = true)
protected Person person;
/**
* Obtiene el valor de la propiedad person.
*
* @return
* possible object is
* {@link Person }
*
*/
public Person getPerson() {
return person;
}
/**
* Define el valor de la propiedad person.
*
* @param value
* allowed object is
* {@link Person }
*
*/
public void setPerson(Person value) {
this.person = value;
}
}

View File

@ -1,63 +0,0 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
//
package com.manalejandro.ws.model;
import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the com.manalejandro.ws.model package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: com.manalejandro.ws.model
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link GetPersonRequest }
*
*/
public GetPersonRequest createGetPersonRequest() {
return new GetPersonRequest();
}
/**
* Create an instance of {@link GetPersonResponse }
*
*/
public GetPersonResponse createGetPersonResponse() {
return new GetPersonResponse();
}
/**
* Create an instance of {@link Person }
*
*/
public Person createPerson() {
return new Person();
}
}

View File

@ -1,147 +0,0 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
//
package com.manalejandro.ws.model;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
/**
* <p>Clase Java para Person complex type.
*
* <p>El siguiente fragmento de esquema especifica el contenido que se espera que haya en esta clase.
*
* <pre>
* &lt;complexType name="Person"&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="name" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="telephone" type="{http://www.w3.org/2001/XMLSchema}int"/&gt;
* &lt;element name="address" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="birthday" type="{http://www.w3.org/2001/XMLSchema}date"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "Person", propOrder = {
"name",
"telephone",
"address",
"birthday"
})
public class Person {
@XmlElement(required = true)
protected String name;
protected int telephone;
@XmlElement(required = true)
protected String address;
@XmlElement(required = true)
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar birthday;
/**
* Obtiene el valor de la propiedad name.
*
* @return
* possible object is
* {@link String }
*
*/
public String getName() {
return name;
}
/**
* Define el valor de la propiedad name.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setName(String value) {
this.name = value;
}
/**
* Obtiene el valor de la propiedad telephone.
*
*/
public int getTelephone() {
return telephone;
}
/**
* Define el valor de la propiedad telephone.
*
*/
public void setTelephone(int value) {
this.telephone = value;
}
/**
* Obtiene el valor de la propiedad address.
*
* @return
* possible object is
* {@link String }
*
*/
public String getAddress() {
return address;
}
/**
* Define el valor de la propiedad address.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setAddress(String value) {
this.address = value;
}
/**
* Obtiene el valor de la propiedad birthday.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getBirthday() {
return birthday;
}
/**
* Define el valor de la propiedad birthday.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setBirthday(XMLGregorianCalendar value) {
this.birthday = value;
}
}

View File

@ -1,9 +0,0 @@
//
// Este archivo ha sido generado por la arquitectura JavaTM para la implantación de la referencia de enlace (JAXB) XML v2.3.0
// Visite <a href="https://javaee.github.io/jaxb-v2/">https://javaee.github.io/jaxb-v2/</a>
// Todas las modificaciones realizadas en este archivo se perderán si se vuelve a compilar el esquema de origen.
// Generado el: 2019.05.19 a las 04:09:02 PM CEST
//
@javax.xml.bind.annotation.XmlSchema(namespace = "http://www.manalejandro.com/person", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)
package com.manalejandro.ws.model;

View File

@ -4,7 +4,6 @@ import java.util.GregorianCalendar;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.xml.datatype.DatatypeConfigurationException;
import javax.xml.datatype.DatatypeFactory;
import org.springframework.stereotype.Component;
@ -12,6 +11,8 @@ import org.springframework.util.Assert;
import com.manalejandro.ws.model.Person;
import jakarta.annotation.PostConstruct;
@Component
public class PersonRepository {
private static final Map<String, Person> persons = new HashMap<String, Person>();
@ -39,4 +40,4 @@ public class PersonRepository {
Assert.notNull(name, "The Person's name must not be null");
return persons.get(name);
}
}
}