mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Always use prefix
config annotation attribute
Update use of `@ConfigurationProperties` to prefer the more explicit `prefix` attribute, rather than `value`. See gh-7579
This commit is contained in:
parent
43d432a527
commit
0a6456a748
@ -26,7 +26,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Christian Dupuis
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("management.health.status")
|
||||
@ConfigurationProperties(prefix = "management.health.status")
|
||||
public class HealthIndicatorProperties {
|
||||
|
||||
/**
|
||||
|
@ -29,7 +29,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("endpoints.metrics.filter")
|
||||
@ConfigurationProperties(prefix = "endpoints.metrics.filter")
|
||||
public class MetricFilterProperties {
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
|
||||
* @author Dave Syer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("endpoints.docs")
|
||||
@ConfigurationProperties(prefix = "endpoints.docs")
|
||||
public class DocsMvcEndpoint extends AbstractNamedMvcEndpoint {
|
||||
|
||||
private static final String DOCS_LOCATION = "classpath:/META-INF/resources/spring-boot-actuator/docs/";
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("endpoints.actuator")
|
||||
@ConfigurationProperties(prefix = "endpoints.actuator")
|
||||
public class HalJsonMvcEndpoint extends AbstractNamedMvcEndpoint {
|
||||
|
||||
private final ManagementServletContext managementServletContext;
|
||||
|
@ -54,7 +54,7 @@ import org.springframework.web.bind.annotation.ResponseStatus;
|
||||
* @author Phillip Webb
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("endpoints.heapdump")
|
||||
@ConfigurationProperties(prefix = "endpoints.heapdump")
|
||||
@HypermediaDisabled
|
||||
public class HeapdumpMvcEndpoint extends AbstractNamedMvcEndpoint {
|
||||
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.util.Assert;
|
||||
* @author Andy Wilkinson
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("management.health.diskspace")
|
||||
@ConfigurationProperties(prefix = "management.health.diskspace")
|
||||
public class DiskSpaceHealthIndicatorProperties {
|
||||
|
||||
private static final int MEGABYTES = 1024 * 1024;
|
||||
|
@ -32,7 +32,7 @@ import org.springframework.util.PatternMatchUtils;
|
||||
* @author Simon Buettner
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.metrics.export")
|
||||
@ConfigurationProperties(prefix = "spring.metrics.export")
|
||||
public class MetricExportProperties extends TriggerProperties {
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Vedran Pavic
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.batch")
|
||||
@ConfigurationProperties(prefix = "spring.batch")
|
||||
public class BatchProperties {
|
||||
|
||||
private static final String DEFAULT_SCHEMA_LOCATION = "classpath:org/springframework/"
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.http.MediaType;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.data.rest")
|
||||
@ConfigurationProperties(prefix = "spring.data.rest")
|
||||
public class RepositoryRestProperties {
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.elasticsearch.jest")
|
||||
@ConfigurationProperties(prefix = "spring.elasticsearch.jest")
|
||||
public class JestProperties {
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,7 @@ import org.springframework.util.Assert;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.hazelcast")
|
||||
@ConfigurationProperties(prefix = "spring.hazelcast")
|
||||
public class HazelcastProperties {
|
||||
|
||||
/**
|
||||
|
@ -28,7 +28,7 @@ import org.springframework.core.io.Resource;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.info")
|
||||
@ConfigurationProperties(prefix = "spring.info")
|
||||
public class ProjectInfoProperties {
|
||||
|
||||
private final Build build = new Build();
|
||||
|
@ -50,7 +50,7 @@ abstract class DataSourceConfiguration {
|
||||
static class Tomcat extends DataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.tomcat")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.tomcat")
|
||||
public org.apache.tomcat.jdbc.pool.DataSource dataSource(
|
||||
DataSourceProperties properties) {
|
||||
org.apache.tomcat.jdbc.pool.DataSource dataSource = createDataSource(
|
||||
@ -75,7 +75,7 @@ abstract class DataSourceConfiguration {
|
||||
static class Hikari extends DataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.hikari")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.hikari")
|
||||
public HikariDataSource dataSource(DataSourceProperties properties) {
|
||||
return createDataSource(properties, HikariDataSource.class);
|
||||
}
|
||||
@ -93,7 +93,7 @@ abstract class DataSourceConfiguration {
|
||||
static class Dbcp extends DataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.dbcp")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.dbcp")
|
||||
public org.apache.commons.dbcp.BasicDataSource dataSource(
|
||||
DataSourceProperties properties) {
|
||||
org.apache.commons.dbcp.BasicDataSource dataSource = createDataSource(
|
||||
@ -118,7 +118,7 @@ abstract class DataSourceConfiguration {
|
||||
static class Dbcp2 extends DataSourceConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.datasource.dbcp2")
|
||||
@ConfigurationProperties(prefix = "spring.datasource.dbcp2")
|
||||
public org.apache.commons.dbcp2.BasicDataSource dataSource(
|
||||
DataSourceProperties properties) {
|
||||
return createDataSource(properties,
|
||||
|
@ -29,7 +29,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.jersey")
|
||||
@ConfigurationProperties(prefix = "spring.jersey")
|
||||
public class JerseyProperties {
|
||||
|
||||
/**
|
||||
|
@ -54,7 +54,7 @@ class ActiveMQConnectionFactoryConfiguration {
|
||||
|
||||
@Bean(destroyMethod = "stop")
|
||||
@ConditionalOnProperty(prefix = "spring.activemq.pool", name = "enabled", havingValue = "true", matchIfMissing = false)
|
||||
@ConfigurationProperties("spring.activemq.pool.configuration")
|
||||
@ConfigurationProperties(prefix = "spring.activemq.pool.configuration")
|
||||
public PooledConnectionFactory pooledJmsConnectionFactory(
|
||||
ActiveMQProperties properties) {
|
||||
PooledConnectionFactory pooledConnectionFactory = new PooledConnectionFactory(
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.mobile.devicedelegatingviewresolver")
|
||||
@ConfigurationProperties(prefix = "spring.mobile.devicedelegatingviewresolver")
|
||||
public class DeviceDelegatingViewResolverProperties {
|
||||
|
||||
/**
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("security.oauth2.client")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.client")
|
||||
public class OAuth2ClientProperties {
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Dave Syer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("security.oauth2.authorization")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.authorization")
|
||||
public class AuthorizationServerProperties {
|
||||
|
||||
/**
|
||||
|
@ -174,7 +174,7 @@ public class OAuth2AuthorizationServerConfiguration
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("security.oauth2.client")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.client")
|
||||
public BaseClientDetails oauth2ClientDetails() {
|
||||
BaseClientDetails details = new BaseClientDetails();
|
||||
if (this.client.getClientId() == null) {
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.security.oauth2.client.token.grant.code.Authorization
|
||||
class OAuth2ProtectedResourceDetailsConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("security.oauth2.client")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.client")
|
||||
@Primary
|
||||
public AuthorizationCodeResourceDetails oauth2RemoteResource() {
|
||||
return new AuthorizationCodeResourceDetails();
|
||||
|
@ -74,7 +74,7 @@ public class OAuth2RestOperationsConfiguration {
|
||||
protected static class SingletonScopedConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("security.oauth2.client")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.client")
|
||||
@Primary
|
||||
public ClientCredentialsResourceDetails oauth2RemoteResource() {
|
||||
ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Dave Syer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("security.oauth2.sso")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.sso")
|
||||
public class OAuth2SsoProperties {
|
||||
|
||||
public static final String DEFAULT_LOGIN_PATH = "/login";
|
||||
|
@ -37,7 +37,7 @@ import org.springframework.validation.Validator;
|
||||
* @author Dave Syer
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@ConfigurationProperties("security.oauth2.resource")
|
||||
@ConfigurationProperties(prefix = "security.oauth2.resource")
|
||||
public class ResourceServerProperties implements Validator, BeanFactoryAware {
|
||||
|
||||
@JsonIgnore
|
||||
|
@ -30,7 +30,7 @@ import org.springframework.session.hazelcast.HazelcastFlushMode;
|
||||
* @author Vedran Pavic
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.session")
|
||||
@ConfigurationProperties(prefix = "spring.session")
|
||||
public class SessionProperties {
|
||||
|
||||
/**
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.social.facebook")
|
||||
@ConfigurationProperties(prefix = "spring.social.facebook")
|
||||
public class FacebookProperties extends SocialProperties {
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.social.linkedin")
|
||||
@ConfigurationProperties(prefix = "spring.social.linkedin")
|
||||
public class LinkedInProperties extends SocialProperties {
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.social.twitter")
|
||||
@ConfigurationProperties(prefix = "spring.social.twitter")
|
||||
public class TwitterProperties extends SocialProperties {
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.util.MimeType;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.2.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.thymeleaf")
|
||||
@ConfigurationProperties(prefix = "spring.thymeleaf")
|
||||
public class ThymeleafProperties {
|
||||
|
||||
private static final Charset DEFAULT_ENCODING = Charset.forName("UTF-8");
|
||||
|
@ -27,7 +27,7 @@ import org.springframework.transaction.support.AbstractPlatformTransactionManage
|
||||
* @author Phillip Webb
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.transaction")
|
||||
@ConfigurationProperties(prefix = "spring.transaction")
|
||||
public class TransactionProperties implements
|
||||
PlatformTransactionManagerCustomizer<AbstractPlatformTransactionManager> {
|
||||
|
||||
|
@ -71,7 +71,7 @@ class BitronixJtaConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConfigurationProperties("spring.jta.bitronix.properties")
|
||||
@ConfigurationProperties(prefix = "spring.jta.bitronix.properties")
|
||||
public bitronix.tm.Configuration bitronixConfiguration() {
|
||||
bitronix.tm.Configuration config = TransactionManagerServices.getConfiguration();
|
||||
if (StringUtils.hasText(this.jtaProperties.getTransactionManagerId())) {
|
||||
|
@ -33,7 +33,7 @@ import org.springframework.validation.DefaultMessageCodesResolver;
|
||||
* @author Eddú Meléndez
|
||||
* @since 1.1
|
||||
*/
|
||||
@ConfigurationProperties("spring.mvc")
|
||||
@ConfigurationProperties(prefix = "spring.mvc")
|
||||
public class WebMvcProperties {
|
||||
|
||||
/**
|
||||
|
@ -31,7 +31,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @author Stephane Nicoll
|
||||
* @since 1.4.0
|
||||
*/
|
||||
@ConfigurationProperties("spring.webservices")
|
||||
@ConfigurationProperties(prefix = "spring.webservices")
|
||||
public class WebServicesProperties {
|
||||
|
||||
/**
|
||||
|
@ -56,7 +56,7 @@ public class RestDocsAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.test.restdocs")
|
||||
@ConfigurationProperties(prefix = "spring.test.restdocs")
|
||||
public RestDocsMockMvcBuilderCustomizer restDocumentationConfigurer(
|
||||
MockMvcRestDocumentationConfigurer configurer,
|
||||
ObjectProvider<RestDocumentationResultHandler> resultHandler) {
|
||||
|
@ -74,7 +74,7 @@ public class MockMvcAutoConfiguration {
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConfigurationProperties("spring.test.mockmvc")
|
||||
@ConfigurationProperties(prefix = "spring.test.mockmvc")
|
||||
public SpringBootMockMvcBuilderCustomizer springBootMockMvcBuilderCustomizer() {
|
||||
return new SpringBootMockMvcBuilderCustomizer(this.context);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
* @since 1.2.0
|
||||
* @see #asProperties()
|
||||
*/
|
||||
@ConfigurationProperties("spring.jta.atomikos.properties")
|
||||
@ConfigurationProperties(prefix = "spring.jta.atomikos.properties")
|
||||
public class AtomikosProperties {
|
||||
|
||||
private final Map<String, String> values = new TreeMap<String, String>();
|
||||
|
Loading…
Reference in New Issue
Block a user