Remove deprecated code flagged for removal

Closes gh-27303
This commit is contained in:
Stephane Nicoll
2021-07-14 11:49:52 +02:00
parent 46ad4c6f98
commit dc5acb0019
82 changed files with 183 additions and 2508 deletions

View File

@@ -1,50 +0,0 @@
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.batch;
import org.springframework.batch.core.explore.JobExplorer;
import org.springframework.batch.core.launch.JobLauncher;
import org.springframework.batch.core.repository.JobRepository;
import org.springframework.boot.ApplicationRunner;
/**
* {@link ApplicationRunner} to {@link JobLauncher launch} Spring Batch jobs. Runs all
* jobs in the surrounding context by default. Can also be used to launch a specific job
* by providing a jobName.
*
* @author Dave Syer
* @author Jean-Pierre Bergamin
* @author Mahmoud Ben Hassine
* @since 1.0.0
* @deprecated since 2.3.0 for removal in 2.6.0 in favor of
* {@link JobLauncherApplicationRunner}
*/
@Deprecated
public class JobLauncherCommandLineRunner extends JobLauncherApplicationRunner {
/**
* Create a new {@link JobLauncherCommandLineRunner}.
* @param jobLauncher to launch jobs
* @param jobExplorer to check the job repository for previous executions
* @param jobRepository to check if a job instance exists with the given parameters
* when running a job
*/
public JobLauncherCommandLineRunner(JobLauncher jobLauncher, JobExplorer jobExplorer, JobRepository jobRepository) {
super(jobLauncher, jobExplorer, jobRepository);
}
}

View File

@@ -1,82 +0,0 @@
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.hazelcast;
import java.io.IOException;
import java.net.URL;
import com.hazelcast.client.HazelcastClient;
import com.hazelcast.client.config.ClientConfig;
import com.hazelcast.client.config.XmlClientConfigBuilder;
import com.hazelcast.client.config.YamlClientConfigBuilder;
import com.hazelcast.core.HazelcastInstance;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
/**
* Factory that can be used to create a client {@link HazelcastInstance}.
*
* @author Vedran Pavic
* @since 2.0.0
* @deprecated since 2.4.3 for removal in 2.6 in favor of using the Hazelcast API directly
*/
@Deprecated
public class HazelcastClientFactory {
private final ClientConfig clientConfig;
/**
* Create a {@link HazelcastClientFactory} for the specified configuration location.
* @param clientConfigLocation the location of the configuration file
* @throws IOException if the configuration location could not be read
*/
public HazelcastClientFactory(Resource clientConfigLocation) throws IOException {
this.clientConfig = getClientConfig(clientConfigLocation);
}
/**
* Create a {@link HazelcastClientFactory} for the specified configuration.
* @param clientConfig the configuration
*/
public HazelcastClientFactory(ClientConfig clientConfig) {
Assert.notNull(clientConfig, "ClientConfig must not be null");
this.clientConfig = clientConfig;
}
private ClientConfig getClientConfig(Resource clientConfigLocation) throws IOException {
URL configUrl = clientConfigLocation.getURL();
String configFileName = configUrl.getPath();
if (configFileName.endsWith(".yaml")) {
return new YamlClientConfigBuilder(configUrl).build();
}
return new XmlClientConfigBuilder(configUrl).build();
}
/**
* Get the {@link HazelcastInstance}.
* @return the {@link HazelcastInstance}
*/
public HazelcastInstance getHazelcastInstance() {
if (StringUtils.hasText(this.clientConfig.getInstanceName())) {
return HazelcastClient.getOrCreateHazelcastClient(this.clientConfig);
}
return HazelcastClient.newHazelcastClient(this.clientConfig);
}
}

View File

@@ -1,96 +0,0 @@
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.hazelcast;
import java.io.IOException;
import java.net.URL;
import com.hazelcast.config.Config;
import com.hazelcast.config.XmlConfigBuilder;
import com.hazelcast.config.YamlConfigBuilder;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.HazelcastInstance;
import org.springframework.core.io.Resource;
import org.springframework.util.Assert;
import org.springframework.util.ResourceUtils;
import org.springframework.util.StringUtils;
/**
* Factory that can be used to create a {@link HazelcastInstance}.
*
* @author Stephane Nicoll
* @author Phillip Webb
* @since 1.3.0
* @deprecated since 2.4.3 for removal in 2.6 in favor of using the Hazelcast API directly
*/
@Deprecated
public class HazelcastInstanceFactory {
private final Config config;
/**
* Create a {@link HazelcastInstanceFactory} for the specified configuration location.
* @param configLocation the location of the configuration file
* @throws IOException if the configuration location could not be read
*/
public HazelcastInstanceFactory(Resource configLocation) throws IOException {
Assert.notNull(configLocation, "ConfigLocation must not be null");
this.config = getConfig(configLocation);
}
/**
* Create a {@link HazelcastInstanceFactory} for the specified configuration.
* @param config the configuration
*/
public HazelcastInstanceFactory(Config config) {
Assert.notNull(config, "Config must not be null");
this.config = config;
}
private Config getConfig(Resource configLocation) throws IOException {
URL configUrl = configLocation.getURL();
Config config = createConfig(configUrl);
if (ResourceUtils.isFileURL(configUrl)) {
config.setConfigurationFile(configLocation.getFile());
}
else {
config.setConfigurationUrl(configUrl);
}
return config;
}
private static Config createConfig(URL configUrl) throws IOException {
String configFileName = configUrl.getPath();
if (configFileName.endsWith(".yaml")) {
return new YamlConfigBuilder(configUrl).build();
}
return new XmlConfigBuilder(configUrl).build();
}
/**
* Get the {@link HazelcastInstance}.
* @return the {@link HazelcastInstance}
*/
public HazelcastInstance getHazelcastInstance() {
if (StringUtils.hasText(this.config.getInstanceName())) {
return Hazelcast.getOrCreateHazelcastInstance(this.config);
}
return Hazelcast.newHazelcastInstance(this.config);
}
}

View File

@@ -20,7 +20,6 @@ import com.mongodb.ConnectionString;
import org.bson.UuidRepresentation;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/**
* Configuration properties for Mongo.
@@ -195,23 +194,6 @@ public class MongoProperties {
return this.gridfs;
}
/**
* Return the GridFS database name.
* @return the GridFS database name
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
* {@link Gridfs#getDatabase()}
*/
@DeprecatedConfigurationProperty(replacement = "spring.data.mongodb.gridfs.database")
@Deprecated
public String getGridFsDatabase() {
return this.gridfs.getDatabase();
}
@Deprecated
public void setGridFsDatabase(String gridFsDatabase) {
this.gridfs.setDatabase(gridFsDatabase);
}
public String getMongoClientDatabase() {
if (this.database != null) {
return this.database;

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -20,12 +20,9 @@ import org.springframework.boot.autoconfigure.condition.ConditionMessage;
import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.boot.autoconfigure.web.WebProperties.Resources.Chain;
import org.springframework.boot.context.properties.bind.BindResult;
import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.ClassUtils;
@@ -45,10 +42,9 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
@Override
public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
ConfigurableEnvironment environment = (ConfigurableEnvironment) context.getEnvironment();
String prefix = determineResourcePropertiesPrefix(environment);
boolean fixed = getEnabledProperty(environment, prefix, "strategy.fixed.", false);
boolean content = getEnabledProperty(environment, prefix, "strategy.content.", false);
Boolean chain = getEnabledProperty(environment, prefix, "", null);
boolean fixed = getEnabledProperty(environment, "strategy.fixed.", false);
boolean content = getEnabledProperty(environment, "strategy.content.", false);
Boolean chain = getEnabledProperty(environment, "", null);
Boolean match = Chain.getEnabled(fixed, content, chain);
ConditionMessage.Builder message = ConditionMessage.forCondition(ConditionalOnEnabledResourceChain.class);
if (match == null) {
@@ -63,19 +59,8 @@ class OnEnabledResourceChainCondition extends SpringBootCondition {
return ConditionOutcome.noMatch(message.because("disabled"));
}
@SuppressWarnings("deprecation")
private String determineResourcePropertiesPrefix(Environment environment) {
BindResult<org.springframework.boot.autoconfigure.web.ResourceProperties> result = Binder.get(environment)
.bind("spring.resources", org.springframework.boot.autoconfigure.web.ResourceProperties.class);
if (result.isBound() && result.get().hasBeenCustomized()) {
return "spring.resources.chain.";
}
return "spring.web.resources.chain.";
}
private Boolean getEnabledProperty(ConfigurableEnvironment environment, String prefix, String key,
Boolean defaultValue) {
String name = prefix + key + "enabled";
private Boolean getEnabledProperty(ConfigurableEnvironment environment, String key, Boolean defaultValue) {
String name = "spring.web.resources.chain." + key + "enabled";
return environment.getProperty(name, Boolean.class, defaultValue);
}

View File

@@ -1,282 +0,0 @@
/*
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.web;
import java.time.Duration;
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.DeprecatedConfigurationProperty;
/**
* Properties used to configure resource handling.
*
* @author Phillip Webb
* @author Brian Clozel
* @author Dave Syer
* @author Venil Noronha
* @author Kristine Jetzke
* @since 1.1.0
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
* {@link WebProperties.Resources}
*/
@Deprecated
@ConfigurationProperties(prefix = "spring.resources", ignoreUnknownFields = false)
public class ResourceProperties extends Resources {
private final Chain chain = new Chain();
private final Cache cache = new Cache();
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.static-locations")
public String[] getStaticLocations() {
return super.getStaticLocations();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.add-mappings")
public boolean isAddMappings() {
return super.isAddMappings();
}
@Override
public Chain getChain() {
return this.chain;
}
@Override
public Cache getCache() {
return this.cache;
}
@Deprecated
public static class Chain extends Resources.Chain {
private final org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy strategy = new org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy();
/**
* Whether to enable HTML5 application cache manifest rewriting.
*/
private boolean htmlApplicationCache = false;
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.enabled")
public Boolean getEnabled() {
return super.getEnabled();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.cache")
public boolean isCache() {
return super.isCache();
}
@DeprecatedConfigurationProperty(reason = "The appcache manifest feature is being removed from browsers.")
public boolean isHtmlApplicationCache() {
return this.htmlApplicationCache;
}
public void setHtmlApplicationCache(boolean htmlApplicationCache) {
this.htmlApplicationCache = htmlApplicationCache;
this.customized = true;
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.compressed")
public boolean isCompressed() {
return super.isCompressed();
}
@Override
public org.springframework.boot.autoconfigure.web.ResourceProperties.Strategy getStrategy() {
return this.strategy;
}
}
/**
* Strategies for extracting and embedding a resource version in its URL path.
*/
@Deprecated
public static class Strategy extends Resources.Chain.Strategy {
private final org.springframework.boot.autoconfigure.web.ResourceProperties.Fixed fixed = new org.springframework.boot.autoconfigure.web.ResourceProperties.Fixed();
private final org.springframework.boot.autoconfigure.web.ResourceProperties.Content content = new org.springframework.boot.autoconfigure.web.ResourceProperties.Content();
@Override
public org.springframework.boot.autoconfigure.web.ResourceProperties.Fixed getFixed() {
return this.fixed;
}
@Override
public org.springframework.boot.autoconfigure.web.ResourceProperties.Content getContent() {
return this.content;
}
}
/**
* Version Strategy based on content hashing.
*/
@Deprecated
public static class Content extends Resources.Chain.Strategy.Content {
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.content.enabled")
public boolean isEnabled() {
return super.isEnabled();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.content.paths")
public String[] getPaths() {
return super.getPaths();
}
}
/**
* Version Strategy based on a fixed version string.
*/
@Deprecated
public static class Fixed extends Resources.Chain.Strategy.Fixed {
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.fixed.enabled")
public boolean isEnabled() {
return super.isEnabled();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.fixed.paths")
public String[] getPaths() {
return super.getPaths();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.chain.strategy.fixed.version")
public String getVersion() {
return super.getVersion();
}
}
/**
* Cache configuration.
*/
@Deprecated
public static class Cache extends Resources.Cache {
private final Cachecontrol cachecontrol = new Cachecontrol();
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.period")
public Duration getPeriod() {
return super.getPeriod();
}
@Override
public Cachecontrol getCachecontrol() {
return this.cachecontrol;
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.use-last-modified")
public boolean isUseLastModified() {
return super.isUseLastModified();
}
/**
* Cache Control HTTP header configuration.
*/
@Deprecated
public static class Cachecontrol extends Resources.Cache.Cachecontrol {
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.max-age")
public Duration getMaxAge() {
return super.getMaxAge();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.no-cache")
public Boolean getNoCache() {
return super.getNoCache();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.no-store")
public Boolean getNoStore() {
return super.getNoStore();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.must-revalidate")
public Boolean getMustRevalidate() {
return super.getMustRevalidate();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.no-transform")
public Boolean getNoTransform() {
return super.getNoTransform();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.cache-public")
public Boolean getCachePublic() {
return super.getCachePublic();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.cache-private")
public Boolean getCachePrivate() {
return super.getCachePrivate();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.proxy-revalidate")
public Boolean getProxyRevalidate() {
return super.getProxyRevalidate();
}
@Override
@DeprecatedConfigurationProperty(
replacement = "spring.web.resources.cache.cachecontrol.stale-while-revalidate")
public Duration getStaleWhileRevalidate() {
return super.getStaleWhileRevalidate();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.stale-if-error")
public Duration getStaleIfError() {
return super.getStaleIfError();
}
@Override
@DeprecatedConfigurationProperty(replacement = "spring.web.resources.cache.cachecontrol.s-max-age")
public Duration getSMaxAge() {
return super.getSMaxAge();
}
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,11 +52,6 @@ class ResourceChainResourceHandlerRegistrationCustomizer implements ResourceHand
if (strategy.getFixed().isEnabled() || strategy.getContent().isEnabled()) {
chain.addResolver(getVersionResourceResolver(strategy));
}
if ((properties instanceof org.springframework.boot.autoconfigure.web.ResourceProperties.Chain)
&& ((org.springframework.boot.autoconfigure.web.ResourceProperties.Chain) properties)
.isHtmlApplicationCache()) {
chain.addTransformer(new org.springframework.web.reactive.resource.AppCacheManifestTransformer());
}
}
private ResourceResolver getVersionResourceResolver(Resources.Chain.Strategy properties) {

View File

@@ -115,11 +115,8 @@ public class WebFluxAutoConfiguration {
@Bean
@SuppressWarnings("deprecation")
public RouterFunctionMapping welcomePageRouterFunctionMapping(ApplicationContext applicationContext,
WebFluxProperties webFluxProperties,
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties) {
String[] staticLocations = resourceProperties.hasBeenCustomized() ? resourceProperties.getStaticLocations()
: webProperties.getResources().getStaticLocations();
WebFluxProperties webFluxProperties, WebProperties webProperties) {
String[] staticLocations = webProperties.getResources().getStaticLocations();
WelcomePageRouterFunctionFactory factory = new WelcomePageRouterFunctionFactory(
new TemplateAvailabilityProviders(applicationContext), applicationContext, staticLocations,
webFluxProperties.getStaticPathPattern());
@@ -136,8 +133,7 @@ public class WebFluxAutoConfiguration {
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({ org.springframework.boot.autoconfigure.web.ResourceProperties.class,
WebProperties.class, WebFluxProperties.class })
@EnableConfigurationProperties({ WebProperties.class, WebFluxProperties.class })
@Import({ EnableWebFluxConfiguration.class })
@Order(0)
public static class WebFluxConfig implements WebFluxConfigurer {
@@ -158,14 +154,12 @@ public class WebFluxAutoConfiguration {
private final ObjectProvider<ViewResolver> viewResolvers;
public WebFluxConfig(org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties, WebFluxProperties webFluxProperties, ListableBeanFactory beanFactory,
ObjectProvider<HandlerMethodArgumentResolver> resolvers,
public WebFluxConfig(WebProperties webProperties, WebFluxProperties webFluxProperties,
ListableBeanFactory beanFactory, ObjectProvider<HandlerMethodArgumentResolver> resolvers,
ObjectProvider<CodecCustomizer> codecCustomizers,
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizer,
ObjectProvider<ViewResolver> viewResolvers) {
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
: webProperties.getResources();
this.resourceProperties = webProperties.getResources();
this.webFluxProperties = webFluxProperties;
this.beanFactory = beanFactory;
this.argumentResolvers = resolvers;
@@ -331,13 +325,9 @@ public class WebFluxAutoConfiguration {
static class ResourceChainCustomizerConfiguration {
@Bean
@SuppressWarnings("deprecation")
ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer(
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties) {
Resources resources = resourceProperties.hasBeenCustomized() ? resourceProperties
: webProperties.getResources();
return new ResourceChainResourceHandlerRegistrationCustomizer(resources);
return new ResourceChainResourceHandlerRegistrationCustomizer(webProperties.getResources());
}
}

View File

@@ -92,21 +92,6 @@ public abstract class AbstractErrorWebExceptionHandler implements ErrorWebExcept
private List<ViewResolver> viewResolvers = Collections.emptyList();
/**
* Create a new {@code AbstractErrorWebExceptionHandler}.
* @param errorAttributes the error attributes
* @param resourceProperties the resource properties
* @param applicationContext the application context
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
* {@link #AbstractErrorWebExceptionHandler(ErrorAttributes, Resources, ApplicationContext)}
*/
@Deprecated
public AbstractErrorWebExceptionHandler(ErrorAttributes errorAttributes,
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
ApplicationContext applicationContext) {
this(errorAttributes, (Resources) resourceProperties, applicationContext);
}
/**
* Create a new {@code AbstractErrorWebExceptionHandler}.
* @param errorAttributes the error attributes

View File

@@ -91,22 +91,6 @@ public class DefaultErrorWebExceptionHandler extends AbstractErrorWebExceptionHa
private final ErrorProperties errorProperties;
/**
* Create a new {@code DefaultErrorWebExceptionHandler} instance.
* @param errorAttributes the error attributes
* @param resourceProperties the resources configuration properties
* @param errorProperties the error configuration properties
* @param applicationContext the current application context
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
* {@link #DefaultErrorWebExceptionHandler(ErrorAttributes, Resources, ErrorProperties, ApplicationContext)}
*/
@Deprecated
public DefaultErrorWebExceptionHandler(ErrorAttributes errorAttributes,
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
ErrorProperties errorProperties, ApplicationContext applicationContext) {
this(errorAttributes, (Resources) resourceProperties, errorProperties, applicationContext);
}
/**
* Create a new {@code DefaultErrorWebExceptionHandler} instance.
* @param errorAttributes the error attributes

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,8 +53,7 @@ import org.springframework.web.reactive.result.view.ViewResolver;
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
@ConditionalOnClass(WebFluxConfigurer.class)
@AutoConfigureBefore(WebFluxAutoConfiguration.class)
@EnableConfigurationProperties({ ServerProperties.class,
org.springframework.boot.autoconfigure.web.ResourceProperties.class, WebProperties.class })
@EnableConfigurationProperties({ ServerProperties.class, WebProperties.class })
public class ErrorWebFluxAutoConfiguration {
private final ServerProperties serverProperties;
@@ -67,12 +66,10 @@ public class ErrorWebFluxAutoConfiguration {
@ConditionalOnMissingBean(value = ErrorWebExceptionHandler.class, search = SearchStrategy.CURRENT)
@Order(-1)
public ErrorWebExceptionHandler errorWebExceptionHandler(ErrorAttributes errorAttributes,
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties, ObjectProvider<ViewResolver> viewResolvers,
ServerCodecConfigurer serverCodecConfigurer, ApplicationContext applicationContext) {
DefaultErrorWebExceptionHandler exceptionHandler = new DefaultErrorWebExceptionHandler(errorAttributes,
resourceProperties.hasBeenCustomized() ? resourceProperties : webProperties.getResources(),
this.serverProperties.getError(), applicationContext);
webProperties.getResources(), this.serverProperties.getError(), applicationContext);
exceptionHandler.setViewResolvers(viewResolvers.orderedStream().collect(Collectors.toList()));
exceptionHandler.setMessageWriters(serverCodecConfigurer.getWriters());
exceptionHandler.setMessageReaders(serverCodecConfigurer.getReaders());

View File

@@ -19,7 +19,6 @@ package org.springframework.boot.autoconfigure.web.servlet;
import java.time.Duration;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import java.util.Map;
import java.util.function.Consumer;
@@ -180,8 +179,7 @@ public class WebMvcAutoConfiguration {
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@Import(EnableWebMvcConfiguration.class)
@EnableConfigurationProperties({ WebMvcProperties.class,
org.springframework.boot.autoconfigure.web.ResourceProperties.class, WebProperties.class })
@EnableConfigurationProperties({ WebMvcProperties.class, WebProperties.class })
@Order(0)
public static class WebMvcAutoConfigurationAdapter implements WebMvcConfigurer, ServletContextAware {
@@ -203,15 +201,12 @@ public class WebMvcAutoConfiguration {
private ServletContext servletContext;
public WebMvcAutoConfigurationAdapter(
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties, WebMvcProperties mvcProperties, ListableBeanFactory beanFactory,
ObjectProvider<HttpMessageConverters> messageConvertersProvider,
public WebMvcAutoConfigurationAdapter(WebProperties webProperties, WebMvcProperties mvcProperties,
ListableBeanFactory beanFactory, ObjectProvider<HttpMessageConverters> messageConvertersProvider,
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider,
ObjectProvider<DispatcherServletPath> dispatcherServletPath,
ObjectProvider<ServletRegistrationBean<?>> servletRegistrations) {
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
: webProperties.getResources();
this.resourceProperties = webProperties.getResources();
this.mvcProperties = mvcProperties;
this.beanFactory = beanFactory;
this.messageConvertersProvider = messageConvertersProvider;
@@ -399,15 +394,11 @@ public class WebMvcAutoConfiguration {
private ResourceLoader resourceLoader;
@SuppressWarnings("deprecation")
public EnableWebMvcConfiguration(
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebMvcProperties mvcProperties, WebProperties webProperties,
public EnableWebMvcConfiguration(WebMvcProperties mvcProperties, WebProperties webProperties,
ObjectProvider<WebMvcRegistrations> mvcRegistrationsProvider,
ObjectProvider<ResourceHandlerRegistrationCustomizer> resourceHandlerRegistrationCustomizerProvider,
ListableBeanFactory beanFactory) {
this.resourceProperties = resourceProperties.hasBeenCustomized() ? resourceProperties
: webProperties.getResources();
this.resourceProperties = webProperties.getResources();
this.mvcProperties = mvcProperties;
this.webProperties = webProperties;
this.mvcRegistrations = mvcRegistrationsProvider.getIfUnique();
@@ -464,18 +455,12 @@ public class WebMvcAutoConfiguration {
@Override
@Bean
@ConditionalOnMissingBean(name = DispatcherServlet.LOCALE_RESOLVER_BEAN_NAME)
@SuppressWarnings("deprecation")
public LocaleResolver localeResolver() {
if (this.webProperties.getLocaleResolver() == WebProperties.LocaleResolver.FIXED) {
return new FixedLocaleResolver(this.webProperties.getLocale());
}
if (this.mvcProperties.getLocaleResolver() == WebMvcProperties.LocaleResolver.FIXED) {
return new FixedLocaleResolver(this.mvcProperties.getLocale());
}
AcceptHeaderLocaleResolver localeResolver = new AcceptHeaderLocaleResolver();
Locale locale = (this.webProperties.getLocale() != null) ? this.webProperties.getLocale()
: this.mvcProperties.getLocale();
localeResolver.setDefaultLocale(locale);
localeResolver.setDefaultLocale(this.webProperties.getLocale());
return localeResolver;
}
@@ -616,12 +601,9 @@ public class WebMvcAutoConfiguration {
static class ResourceChainCustomizerConfiguration {
@Bean
@SuppressWarnings("deprecation")
ResourceChainResourceHandlerRegistrationCustomizer resourceHandlerRegistrationCustomizer(
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties) {
return new ResourceChainResourceHandlerRegistrationCustomizer(
resourceProperties.hasBeenCustomized() ? resourceProperties : webProperties.getResources());
return new ResourceChainResourceHandlerRegistrationCustomizer(webProperties.getResources());
}
}
@@ -646,7 +628,6 @@ public class WebMvcAutoConfiguration {
configureResourceChain(properties, registration.resourceChain(properties.isCache()));
}
@SuppressWarnings("deprecation")
private void configureResourceChain(Resources.Chain properties, ResourceChainRegistration chain) {
Strategy strategy = properties.getStrategy();
if (properties.isCompressed()) {
@@ -655,11 +636,6 @@ public class WebMvcAutoConfiguration {
if (strategy.getFixed().isEnabled() || strategy.getContent().isEnabled()) {
chain.addResolver(getVersionResourceResolver(strategy));
}
if (properties instanceof org.springframework.boot.autoconfigure.web.ResourceProperties.Chain
&& ((org.springframework.boot.autoconfigure.web.ResourceProperties.Chain) properties)
.isHtmlApplicationCache()) {
chain.addTransformer(new org.springframework.web.servlet.resource.AppCacheManifestTransformer());
}
}
private ResourceResolver getVersionResourceResolver(Strategy properties) {

View File

@@ -18,7 +18,6 @@ package org.springframework.boot.autoconfigure.web.servlet;
import java.time.Duration;
import java.util.LinkedHashMap;
import java.util.Locale;
import java.util.Map;
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -46,17 +45,6 @@ public class WebMvcProperties {
*/
private DefaultMessageCodesResolver.Format messageCodesResolverFormat;
/**
* Locale to use. By default, this locale is overridden by the "Accept-Language"
* header.
*/
private Locale locale;
/**
* Define how the locale should be resolved.
*/
private LocaleResolver localeResolver = LocaleResolver.ACCEPT_HEADER;
private final Format format = new Format();
/**
@@ -121,26 +109,6 @@ public class WebMvcProperties {
this.messageCodesResolverFormat = messageCodesResolverFormat;
}
@Deprecated
@DeprecatedConfigurationProperty(replacement = "spring.web.locale")
public Locale getLocale() {
return this.locale;
}
public void setLocale(Locale locale) {
this.locale = locale;
}
@Deprecated
@DeprecatedConfigurationProperty(replacement = "spring.web.locale-resolver")
public LocaleResolver getLocaleResolver() {
return this.localeResolver;
}
public void setLocaleResolver(LocaleResolver localeResolver) {
this.localeResolver = localeResolver;
}
@Deprecated
@DeprecatedConfigurationProperty(replacement = "spring.mvc.format.date")
public String getDateFormat() {
@@ -547,25 +515,4 @@ public class WebMvcProperties {
}
/**
* Locale resolution options.
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
* {@link org.springframework.boot.autoconfigure.web.WebProperties.LocaleResolver}
*/
@Deprecated
public enum LocaleResolver {
/**
* Always use the configured locale.
*/
FIXED,
/**
* Use the "Accept-Language" header or the configured locale if the header is not
* set.
*/
ACCEPT_HEADER
}
}

View File

@@ -74,19 +74,6 @@ public class DefaultErrorViewResolver implements ErrorViewResolver, Ordered {
private int order = Ordered.LOWEST_PRECEDENCE;
/**
* Create a new {@link DefaultErrorViewResolver} instance.
* @param applicationContext the source application context
* @param resourceProperties resource properties
* @deprecated since 2.4.0 for removal in 2.6.0 in favor of
* {@link #DefaultErrorViewResolver(ApplicationContext, Resources)}
*/
@Deprecated
public DefaultErrorViewResolver(ApplicationContext applicationContext,
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties) {
this(applicationContext, (Resources) resourceProperties);
}
/**
* Create a new {@link DefaultErrorViewResolver} instance.
* @param applicationContext the source application context

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2012-2020 the original author or authors.
* Copyright 2012-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -124,20 +124,16 @@ public class ErrorMvcAutoConfiguration {
@SuppressWarnings("deprecation")
@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties({ org.springframework.boot.autoconfigure.web.ResourceProperties.class,
WebProperties.class, WebMvcProperties.class })
@EnableConfigurationProperties({ WebProperties.class, WebMvcProperties.class })
static class DefaultErrorViewResolverConfiguration {
private final ApplicationContext applicationContext;
private final Resources resources;
DefaultErrorViewResolverConfiguration(ApplicationContext applicationContext,
org.springframework.boot.autoconfigure.web.ResourceProperties resourceProperties,
WebProperties webProperties) {
DefaultErrorViewResolverConfiguration(ApplicationContext applicationContext, WebProperties webProperties) {
this.applicationContext = applicationContext;
this.resources = webProperties.getResources().hasBeenCustomized() ? webProperties.getResources()
: resourceProperties;
this.resources = webProperties.getResources();
}
@Bean

View File

@@ -1585,10 +1585,6 @@
"description": "Whether to enable Spring's HiddenHttpMethodFilter.",
"defaultValue": false
},
{
"name": "spring.mvc.locale-resolver",
"defaultValue": "accept-header"
},
{
"name": "spring.mvc.pathmatch.matching-strategy",
"defaultValue": "ant-path-matcher"
@@ -1682,7 +1678,7 @@
"type": "java.lang.Boolean",
"description": "Whether to enable resolution of already gzipped resources. Checks for a resource name variant with the \"*.gz\" extension.",
"deprecation": {
"replacement": "spring.resources.chain.compressed",
"replacement": "spring.web.resources.chain.compressed",
"level": "error"
}
},