use of org.springframework.context.annotation.Primary in project irida by phac-nml.
the class IridaWebSecurityConfig method tokenServices.
@Bean
@Primary
public ResourceServerTokenServices tokenServices(@Qualifier("clientDetails") ClientDetailsService clientDetails, @Qualifier("iridaTokenStore") TokenStore tokenStore) {
DefaultTokenServices services = new DefaultTokenServices();
services.setTokenStore(tokenStore);
services.setSupportRefreshToken(true);
services.setClientDetailsService(clientDetails);
return services;
}
use of org.springframework.context.annotation.Primary in project giftcard-demo-series by AxonIQ.
the class PrimaryJpaConfig method flyway.
/**
**********************************************************************
* Using Flyway to do the required schema creation/updates
***********************************************************************
*/
@Bean
@Primary
@ConfigurationProperties(prefix = "primary.flyway")
public Flyway flyway(DataSource dataSource) {
Flyway flyway = new Flyway();
flyway.setDataSource(dataSource);
return flyway;
}
use of org.springframework.context.annotation.Primary in project litemall by linlinjava.
the class JacksonConfig method objectMapper.
@Bean
@Primary
public ObjectMapper objectMapper(Jackson2ObjectMapperBuilder builder) {
JavaTimeModule javaTimeModule = new JavaTimeModule();
javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ofPattern("HH:mm:ss")));
ObjectMapper objectMapper = builder.createXmlMapper(false).build();
objectMapper.registerModule(javaTimeModule);
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
return objectMapper;
}
use of org.springframework.context.annotation.Primary in project nifi-registry by apache.
the class DataSourceFactory method getDataSource.
@Bean
@Primary
public DataSource getDataSource() {
if (connectionPool == null) {
// locate the repository directory
final String repositoryDirectoryPath = properties.getDatabaseDirectory();
// ensure the repository directory is specified
if (repositoryDirectoryPath == null) {
throw new NullPointerException("Database directory must be specified.");
}
// create a handle to the repository directory
final File repositoryDirectory = new File(repositoryDirectoryPath);
// get a handle to the database file
final File databaseFile = new File(repositoryDirectory, DATABASE_FILE_NAME);
// format the database url
String databaseUrl = "jdbc:h2:" + databaseFile + ";AUTOCOMMIT=OFF;DB_CLOSE_ON_EXIT=FALSE;LOCK_MODE=3";
String databaseUrlAppend = properties.getDatabaseUrlAppend();
if (StringUtils.isNotBlank(databaseUrlAppend)) {
databaseUrl += databaseUrlAppend;
}
// create the pool
connectionPool = JdbcConnectionPool.create(databaseUrl, DB_USERNAME_PASSWORD, DB_USERNAME_PASSWORD);
connectionPool.setMaxConnections(MAX_CONNECTIONS);
}
return connectionPool;
}
use of org.springframework.context.annotation.Primary in project springBoot-learn-demo by nbfujx.
the class DruidConfig method sqlSessionFactory.
@Bean
@Primary
public // 配置session工厂,不配置默认加载最后一个数据源的
SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
bean.setDataSource(dataSource());
bean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapping/**/*.xml"));
return bean.getObject();
}
Aggregations