use of org.springframework.context.annotation.Primary in project thingsboard by thingsboard.
the class ThingsboardMessageConfiguration method messageSource.
@Bean
@Primary
public MessageSource messageSource() {
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setBasename("i18n/messages");
messageSource.setDefaultEncoding("UTF-8");
return messageSource;
}
use of org.springframework.context.annotation.Primary in project cloud-sea-towerman by huadahuang1983.
the class OAuthServerConfig method tokenServices.
@Primary
@Bean
public AuthorizationServerTokenServices tokenServices() {
DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
defaultTokenServices.setTokenStore(tokenStore());
defaultTokenServices.setSupportRefreshToken(true);
defaultTokenServices.setClientDetailsService(clientDetailsService());
// 有效期设置
defaultTokenServices.setAccessTokenValiditySeconds((int) TimeUnit.HOURS.toSeconds(2));
return defaultTokenServices;
}
use of org.springframework.context.annotation.Primary in project cloud-sea-towerman by huadahuang1983.
the class DataSourceConfig method druidDataSource.
@Bean
@Primary
public DataSource druidDataSource() {
DruidDataSource datasource = new DruidDataSource();
datasource.setUrl(this.dbUrl);
datasource.setUsername(username);
datasource.setPassword(password);
datasource.setDriverClassName(driverClassName);
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);
try {
datasource.setFilters(filters);
} catch (SQLException e) {
logger.error("druid configuration initialization filter", e);
}
return datasource;
}
use of org.springframework.context.annotation.Primary in project Backend by FredBoat.
the class DatabaseConfiguration method mainDbConn.
@Primary
@Bean
public DatabaseConnection mainDbConn(DatabaseManager databaseManager) throws InterruptedException {
// attempt to connect to the database a few times
// this is relevant in a dockerized environment because after a reboot there is no guarantee that the db
// container will be started before the fredboat one
int dbConnectionAttempts = 0;
DatabaseConnection mainDbConn = null;
while ((mainDbConn == null || !mainDbConn.isAvailable()) && dbConnectionAttempts++ < 10) {
try {
if (mainDbConn != null) {
mainDbConn.shutdown();
}
mainDbConn = databaseManager.getMainDbConn();
} catch (Exception e) {
log.info("Could not connect to the database. Retrying in a moment...", e);
Thread.sleep(6000);
}
}
if (mainDbConn == null || !mainDbConn.isAvailable()) {
String message = "Could not establish database connection. Exiting...";
log.error(message);
System.exit(1);
}
return mainDbConn;
}
use of org.springframework.context.annotation.Primary in project spring-boot-admin by codecentric.
the class NotifierConfig method remindingNotifier.
@Primary
@Bean(initMethod = "start", destroyMethod = "stop")
public RemindingNotifier remindingNotifier() {
// <2>
RemindingNotifier notifier = new RemindingNotifier(filteringNotifier(), this.repository);
notifier.setReminderPeriod(Duration.ofMinutes(10));
notifier.setCheckReminderInverval(Duration.ofSeconds(10));
return notifier;
}
Aggregations