use of org.springframework.context.annotation.Primary in project dhis2-core by dhis2.
the class DhisWebApiWebSecurityConfig method tokenServices.
@Bean("defaultTokenService")
@Primary
public DefaultTokenServices tokenServices() {
final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setSupportRefreshToken(true);
return defaultTokenServices;
}
use of org.springframework.context.annotation.Primary in project dhis2-core by dhis2.
the class WebMvcConfig method mvcContentNegotiationManager.
@Primary
@Bean
@Override
public ContentNegotiationManager mvcContentNegotiationManager() {
CustomPathExtensionContentNegotiationStrategy pathExtensionNegotiationStrategy = new CustomPathExtensionContentNegotiationStrategy(mediaTypeMap);
pathExtensionNegotiationStrategy.setUseRegisteredExtensionsOnly(true);
return new ContentNegotiationManager(Arrays.asList(pathExtensionNegotiationStrategy, new HeaderContentNegotiationStrategy(), new FixedContentNegotiationStrategy(MediaType.APPLICATION_JSON)));
}
use of org.springframework.context.annotation.Primary in project grails-core by grails.
the class MimeTypesConfiguration method mimeTypes.
@Bean("mimeTypes")
@Primary
protected MimeType[] mimeTypes() {
final Config config = grailsApplication.getConfig();
final Map<CharSequence, Object> mimeConfig = getMimeConfig(config);
MimeType[] mimeTypes;
if (mimeConfig == null || mimeConfig.isEmpty()) {
mimeTypes = MimeType.createDefaults();
return mimeTypes;
} else {
List<MimeType> mimes = new ArrayList<>();
for (Map.Entry<CharSequence, Object> entry : mimeConfig.entrySet()) {
final String key = entry.getKey().toString();
final Object v = entry.getValue();
if (v instanceof List) {
List list = (List) v;
for (Object i : list) {
mimes.add(new MimeType(i.toString(), key));
}
} else {
mimes.add(new MimeType(v.toString(), key));
}
}
final List<MimeTypeProvider> mimeTypeProviders = this.mimeTypeProviders;
processProviders(mimes, mimeTypeProviders);
final Map<String, MimeTypeProvider> childTypes = applicationContext.getBeansOfType(MimeTypeProvider.class);
processProviders(mimes, childTypes.values());
mimeTypes = mimes.toArray(new MimeType[0]);
return mimeTypes;
}
}
use of org.springframework.context.annotation.Primary in project new-cloud by xie-summer.
the class ResourceServerConfiguration method tokenServices.
@Bean
@Primary
public DefaultTokenServices tokenServices() {
final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setTokenEnhancer(accessTokenConverter());
return defaultTokenServices;
}
use of org.springframework.context.annotation.Primary in project new-cloud by xie-summer.
the class DruidDbConfig method dataSource.
/**
* @return 声明其为Bean实例
* 在同样的DataSource中,首先使用被标注的DataSource
*/
@Bean
@Primary
public DataSource dataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
// configuration
datasource.setInitialSize(initialSize);
datasource.setMinIdle(minIdle);
datasource.setMaxActive(maxActive);
datasource.setMaxWait(maxWait);
datasource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
datasource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
datasource.setValidationQuery(validationQuery);
datasource.setTestWhileIdle(testWhileIdle);
datasource.setTestOnBorrow(testOnBorrow);
datasource.setTestOnReturn(testOnReturn);
datasource.setPoolPreparedStatements(poolPreparedStatements);
datasource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
datasource.setConnectionProperties(connectionProperties);
return datasource;
}
Aggregations