Search in sources :

Example 26 with Primary

use of org.springframework.context.annotation.Primary in project goci by EBISPOT.

the class CurationApplication method getObjectMapper.

@Bean(name = "JodaMapper")
@Primary
public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JodaModule()).configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false).configure(SerializationFeature.INDENT_OUTPUT, true).setSerializationInclusion(JsonInclude.Include.NON_NULL);
    return mapper;
}
Also used : JodaModule(com.fasterxml.jackson.datatype.joda.JodaModule) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 27 with Primary

use of org.springframework.context.annotation.Primary in project pinpoint by naver.

the class FlinkCacheConfiguration method cacheManager.

@Bean
@Primary
public CacheManager cacheManager() {
    CaffeineCacheManager cacheManager = new CaffeineCacheManager();
    cacheManager.setCaffeine(Caffeine.newBuilder().expireAfterWrite(600, TimeUnit.SECONDS).initialCapacity(200).maximumSize(1000));
    return cacheManager;
}
Also used : CaffeineCacheManager(org.springframework.cache.caffeine.CaffeineCacheManager) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 28 with Primary

use of org.springframework.context.annotation.Primary in project spring-boot by spring-projects.

the class JmxAutoConfiguration method mbeanExporter.

@Bean
@Primary
@ConditionalOnMissingBean(value = MBeanExporter.class, search = SearchStrategy.CURRENT)
public AnnotationMBeanExporter mbeanExporter(ObjectNamingStrategy namingStrategy, BeanFactory beanFactory) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String serverBean = this.environment.getProperty("spring.jmx.server", "mbeanServer");
    if (StringUtils.hasLength(serverBean)) {
        exporter.setServer(beanFactory.getBean(serverBean, MBeanServer.class));
    }
    return exporter;
}
Also used : AnnotationMBeanExporter(org.springframework.jmx.export.annotation.AnnotationMBeanExporter) MBeanServer(javax.management.MBeanServer) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Primary(org.springframework.context.annotation.Primary) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) MBeanServerFactoryBean(org.springframework.jmx.support.MBeanServerFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 29 with Primary

use of org.springframework.context.annotation.Primary in project spring-boot by spring-projects.

the class JdbcTemplateConfiguration method jdbcTemplate.

@Bean
@Primary
JdbcTemplate jdbcTemplate(DataSource dataSource, JdbcProperties properties) {
    JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    JdbcProperties.Template template = properties.getTemplate();
    jdbcTemplate.setFetchSize(template.getFetchSize());
    jdbcTemplate.setMaxRows(template.getMaxRows());
    if (template.getQueryTimeout() != null) {
        jdbcTemplate.setQueryTimeout((int) template.getQueryTimeout().getSeconds());
    }
    return jdbcTemplate;
}
Also used : JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) Primary(org.springframework.context.annotation.Primary) ConditionalOnMissingBean(org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean) Bean(org.springframework.context.annotation.Bean)

Example 30 with Primary

use of org.springframework.context.annotation.Primary in project dhis2-core by dhis2.

the class RedisConfiguration method redisTemplate.

@Bean(name = "redisTemplate")
@Primary
public RedisTemplate<?, ?> redisTemplate() {
    RedisTemplate<?, ?> redisTemplate = new RedisTemplate<>();
    redisTemplate.setConnectionFactory(lettuceConnectionFactory());
    redisTemplate.setKeySerializer(new StringRedisSerializer());
    return redisTemplate;
}
Also used : StringRedisSerializer(org.springframework.data.redis.serializer.StringRedisSerializer) StringRedisTemplate(org.springframework.data.redis.core.StringRedisTemplate) RedisTemplate(org.springframework.data.redis.core.RedisTemplate) Primary(org.springframework.context.annotation.Primary) ConfigurationPropertyFactoryBean(org.hisp.dhis.external.conf.ConfigurationPropertyFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

Primary (org.springframework.context.annotation.Primary)87 Bean (org.springframework.context.annotation.Bean)84 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)14 SqlSessionFactoryBean (org.mybatis.spring.SqlSessionFactoryBean)13 SQLException (java.sql.SQLException)10 LocalContainerEntityManagerFactoryBean (org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)10 PathMatchingResourcePatternResolver (org.springframework.core.io.support.PathMatchingResourcePatternResolver)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 JpaTransactionManager (org.springframework.orm.jpa.JpaTransactionManager)7 ServletRegistrationBean (org.springframework.boot.web.servlet.ServletRegistrationBean)6 DefaultTokenServices (org.springframework.security.oauth2.provider.token.DefaultTokenServices)6 JavaTimeModule (com.fasterxml.jackson.datatype.jsr310.JavaTimeModule)4 ConfigurationProperties (org.springframework.boot.context.properties.ConfigurationProperties)4 JodaModule (com.fasterxml.jackson.datatype.joda.JodaModule)3 LocalDateSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer)3 LocalDateTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer)3 LocalTimeSerializer (com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer)3 XmAuthenticationContext (com.icthh.xm.commons.security.XmAuthenticationContext)3 XmAuthenticationContextHolder (com.icthh.xm.commons.security.XmAuthenticationContextHolder)3 FilterRegistrationBean (org.springframework.boot.web.servlet.FilterRegistrationBean)3