Upgrade to Spring Framework 6 and Jakarta EE 9

Closes gh-28619
Closes gh-28620
Closes gh-28621
Closes gh-28622
Closes gh-28623
Closes gh-28624
Closes gh-28625
Closes gh-28626
Closes gh-28627
Closes gh-28628
Closes gh-28629
Closes gh-28630
Closes gh-28631
Closes gh-28632
Closes gh-28633
Closes gh-28634
Closes gh-28635
Closes gh-28636
Closes gh-28638
Closes gh-28639
Closes gh-28640
Closes gh-28644
Closes gh-28645
Closes gh-28650
Closes gh-28711
Closes gh-28866
Closes gh-28867
Closes gh-28868
Closes gh-28872

See gh-28641
See gh-28642
See gh-28643
See gh-28646
See gh-28647
See gh-28648
See gh-28649
See gh-28721
See gh-28869
See gh-28871
This commit is contained in:
Andy Wilkinson
2021-11-30 20:32:16 +00:00
parent 91b2eb1a6f
commit fe7b13ec46
444 changed files with 1642 additions and 2394 deletions

View File

@@ -161,7 +161,7 @@ The following metadata snippet corresponds to the standard `server.servlet.jsp.c
{
"name": "class-reference",
"parameters": {
"target": "javax.servlet.http.HttpServlet"
"target": "jakarta.servlet.http.HttpServlet"
}
}
]

View File

@@ -24,17 +24,14 @@ Spring Boot supports the following embedded servlet containers:
|===
| Name | Servlet Version
| Tomcat 9.0
| 4.0
| Tomcat 10.0
| 5.0
| Jetty 9.4
| 3.1
| Jetty 11.0
| 5.1
| Jetty 10.0
| 4.0
| Undertow 2.0
| 4.0
| Undertow 2.2 (Jakarta EE 9 variant)
| 5.0
|===
You can also deploy Spring Boot applications to any servlet 3.1+ compatible container.
You can also deploy Spring Boot applications to any servlet 5.0+ compatible container.

View File

@@ -141,7 +141,7 @@ See the {spring-boot-autoconfigure-module-code}/web/servlet/WebMvcAutoConfigurat
[[howto.spring-mvc.multipart-file-uploads]]
=== Handling Multipart File Uploads
Spring Boot embraces the servlet 3 `javax.servlet.http.Part` API to support uploading files.
Spring Boot embraces the servlet 5 `jakarta.servlet.http.Part` API to support uploading files.
By default, Spring Boot configures Spring MVC with a maximum size of 1MB per file and a maximum of 10MB of file data in a single request.
You may override these values, the location to which intermediate data is stored (for example, to the `/tmp` directory), and the threshold past which data is flushed to disk by using the properties exposed in the `MultipartProperties` class.
For example, if you want to specify that files be unlimited, set the configprop:spring.servlet.multipart.max-file-size[] property to `-1`.

View File

@@ -497,7 +497,7 @@ If you need to register a `Filter` that interacts with other beans, consider usi
[[web.servlet.embedded-container.context-initializer]]
==== Servlet Context Initialization
Embedded servlet containers do not directly execute the servlet 3.0+ `javax.servlet.ServletContainerInitializer` interface or Spring's `org.springframework.web.WebApplicationInitializer` interface.
Embedded servlet containers do not directly execute the `jakarta.servlet.ServletContainerInitializer` interface or Spring's `org.springframework.web.WebApplicationInitializer` interface.
This is an intentional design decision intended to reduce the risk that third party libraries designed to run inside a war may break Spring Boot applications.
If you need to perform servlet context initialization in a Spring Boot application, you should register a bean that implements the `org.springframework.boot.web.servlet.ServletContextInitializer` interface.

View File

@@ -19,13 +19,13 @@ package org.springframework.boot.docs.actuator.cloudfoundry.customcontextpath;
import java.io.IOException;
import java.util.Collections;
import javax.servlet.GenericServlet;
import javax.servlet.Servlet;
import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import jakarta.servlet.GenericServlet;
import jakarta.servlet.Servlet;
import jakarta.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import org.apache.catalina.Host;
import org.apache.catalina.core.StandardContext;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.data.nosql.elasticsearch.connectingusingspringdata;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.backend.elasticsearch7.ElasticsearchRestTemplate;
import org.springframework.stereotype.Component;
@Component

View File

@@ -18,10 +18,10 @@ package org.springframework.boot.docs.data.sql.jpaandspringdata.entityclasses;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
@Entity
public class City implements Serializable {

View File

@@ -18,10 +18,10 @@ package org.springframework.boot.docs.data.sql.jpaandspringdata.entityclasses;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import org.hibernate.envers.Audited;

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurat
import java.net.InetAddress;
import javax.validation.constraints.NotNull;
import jakarta.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

View File

@@ -18,9 +18,9 @@ package org.springframework.boot.docs.features.externalconfig.typesafeconfigurat
import java.net.InetAddress;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.validation.annotation.Validated;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredwebservices.client;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "request")
class Request {

View File

@@ -16,9 +16,9 @@
package org.springframework.boot.docs.features.testing.springbootapplications.autoconfiguredwebservices.client;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlAccessType;
import jakarta.xml.bind.annotation.XmlAccessorType;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement(name = "response")
@XmlAccessorType(XmlAccessType.FIELD)

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.howto.dataaccess.configureacomponentthatisusedbyjpa;
import javax.persistence.EntityManagerFactory;
import jakarta.persistence.EntityManagerFactory;
import org.springframework.boot.autoconfigure.orm.jpa.EntityManagerFactoryDependsOnPostProcessor;
import org.springframework.stereotype.Component;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.howto.messaging.disabletransactedjmssession;
import javax.jms.ConnectionFactory;
import jakarta.jms.ConnectionFactory;
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.howto.springmvc.writexmlrestservice;
import javax.xml.bind.annotation.XmlRootElement;
import jakarta.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class MyThing {

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.howto.webserver.addservletfilterlistener.springbean.disable;
import javax.servlet.Filter;
import jakarta.servlet.Filter;
public abstract class MyFilter implements Filter {

View File

@@ -16,46 +16,25 @@
package org.springframework.boot.docs.howto.webserver.enablemultipleconnectorsintomcat;
import java.io.IOException;
import java.net.URL;
import org.apache.catalina.connector.Connector;
import org.apache.coyote.http11.Http11NioProtocol;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.ResourceUtils;
@Configuration(proxyBeanMethods = false)
public class MyTomcatConfiguration {
@Bean
public WebServerFactoryCustomizer<TomcatServletWebServerFactory> sslConnectorCustomizer() {
return (tomcat) -> tomcat.addAdditionalTomcatConnectors(createSslConnector());
return (tomcat) -> tomcat.addAdditionalTomcatConnectors(createConnectorConnector());
}
private Connector createSslConnector() {
private Connector createConnectorConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler();
try {
URL keystore = ResourceUtils.getURL("keystore");
URL truststore = ResourceUtils.getURL("truststore");
connector.setScheme("https");
connector.setSecure(true);
connector.setPort(8443);
protocol.setSSLEnabled(true);
protocol.setKeystoreFile(keystore.toString());
protocol.setKeystorePass("changeit");
protocol.setTruststoreFile(truststore.toString());
protocol.setTruststorePass("changeit");
protocol.setKeyAlias("apitester");
return connector;
}
catch (IOException ex) {
throw new IllegalStateException("Fail to create ssl connector", ex);
}
connector.setPort(8080);
return connector;
}
}

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.io.jta.mixingxaandnonxaconnections.nonxa;
import javax.jms.ConnectionFactory;
import jakarta.jms.ConnectionFactory;
import org.springframework.beans.factory.annotation.Qualifier;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.io.jta.mixingxaandnonxaconnections.primary;
import javax.jms.ConnectionFactory;
import jakarta.jms.ConnectionFactory;
public class MyBean {

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.io.jta.mixingxaandnonxaconnections.xa;
import javax.jms.ConnectionFactory;
import jakarta.jms.ConnectionFactory;
import org.springframework.beans.factory.annotation.Qualifier;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.io.validation;
import javax.validation.constraints.Size;
import jakarta.validation.constraints.Size;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.messaging.jms.receiving.custom;
import javax.jms.ConnectionFactory;
import jakarta.jms.ConnectionFactory;
import org.springframework.boot.autoconfigure.jms.DefaultJmsListenerContainerFactoryConfigurer;
import org.springframework.context.annotation.Bean;

View File

@@ -16,9 +16,9 @@
package org.springframework.boot.docs.messaging.jms.receiving.custom;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.Session;
import jakarta.jms.JMSException;
import jakarta.jms.Message;
import jakarta.jms.Session;
import org.springframework.jms.support.converter.MessageConversionException;
import org.springframework.jms.support.converter.MessageConverter;

View File

@@ -16,7 +16,7 @@
package org.springframework.boot.docs.web.servlet.springmvc.errorhandling;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.error.ErrorAttributes;
import org.springframework.stereotype.Controller;

View File

@@ -16,8 +16,8 @@
package org.springframework.boot.docs.web.servlet.springmvc.errorhandling;
import javax.servlet.RequestDispatcher;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.docs.web.servlet.springmvc.errorhandling.errorp
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.autoconfigure.web.servlet.error.ErrorViewResolver;
import org.springframework.http.HttpStatus;

View File

@@ -18,10 +18,10 @@ package org.springframework.boot.docs.web.servlet.springmvc.errorhandling.errorp
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import jakarta.servlet.FilterChain;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.ServletResponse;
import org.springframework.web.filter.GenericFilterBean;

View File

@@ -18,7 +18,7 @@ package org.springframework.boot.docs.web.servlet.springmvc.errorhandling.errorp
import java.util.EnumSet;
import javax.servlet.DispatcherType;
import jakarta.servlet.DispatcherType;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;