Search in sources :

Example 46 with Primary

use of org.springframework.context.annotation.Primary in project ontrack by nemerosa.

the class GitMockConfig method repositoryClientFactory.

@Bean
@Primary
public GitRepositoryClientFactory repositoryClientFactory() {
    GitRepositoryClientFactory factory = mock(GitRepositoryClientFactory.class);
    when(factory.getClient(any(GitRepository.class))).thenReturn(testGitRepositoryClient());
    return factory;
}
Also used : GitRepository(net.nemerosa.ontrack.git.GitRepository) GitRepositoryClientFactory(net.nemerosa.ontrack.git.GitRepositoryClientFactory) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 47 with Primary

use of org.springframework.context.annotation.Primary in project spring-boot-api-seed-project by selfassu.

the class DruidConfigurer method dataSource.

@Bean
@Primary
public DataSource dataSource() {
    logger.info("DruidConfigurer ==> starting init druid datasource.....");
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setDriverClassName(driverClassName);
    dataSource.setUrl(url);
    dataSource.setInitialSize(initialSize);
    dataSource.setMaxActive(maxActive);
    dataSource.setMinIdle(minIdle);
    dataSource.setMaxWait(maxWait);
    dataSource.setPoolPreparedStatements(poolPreparedStatements);
    dataSource.setMaxPoolPreparedStatementPerConnectionSize(maxPoolPreparedStatementPerConnectionSize);
    dataSource.setValidationQuery(validationQuery);
    dataSource.setValidationQueryTimeout(validationQueryTimeout);
    dataSource.setTestOnBorrow(testOnBorrow);
    dataSource.setTestOnReturn(testOnReturn);
    dataSource.setTestWhileIdle(testWhileIdle);
    dataSource.setTimeBetweenEvictionRunsMillis(timeBetweenEvictionRunsMillis);
    dataSource.setMinEvictableIdleTimeMillis(minEvictableIdleTimeMillis);
    dataSource.setAsyncCloseConnectionEnable(asyncCloseConnectionEnable);
    logger.info("DruidConfigurer ==> starting init druid datasource completed.....");
    return dataSource;
}
Also used : DruidDataSource(com.alibaba.druid.pool.DruidDataSource) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 48 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) {
    AnnotationMBeanExporter exporter = new AnnotationMBeanExporter();
    exporter.setRegistrationPolicy(RegistrationPolicy.FAIL_ON_EXISTING);
    exporter.setNamingStrategy(namingStrategy);
    String server = this.propertyResolver.getProperty("server", "mbeanServer");
    if (StringUtils.hasLength(server)) {
        exporter.setServer(this.beanFactory.getBean(server, 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 49 with Primary

use of org.springframework.context.annotation.Primary in project rhino by PLOS.

the class RhinoConfiguration method transactionManager.

@Bean
// and a JmsTransactionManager.
@Primary
public HibernateTransactionManager transactionManager(SessionFactory sessionFactory) {
    HibernateTransactionManager manager = new HibernateTransactionManager();
    manager.setSessionFactory(sessionFactory);
    return manager;
}
Also used : HibernateTransactionManager(org.springframework.orm.hibernate3.HibernateTransactionManager) Primary(org.springframework.context.annotation.Primary) AnnotationSessionFactoryBean(org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 50 with Primary

use of org.springframework.context.annotation.Primary in project perry by ca-cwds.

the class CMSConfiguration method entityManagerFactory.

@Bean
@Primary
@Autowired
public LocalContainerEntityManagerFactoryBean entityManagerFactory(DataSource dataSource) {
    LocalContainerEntityManagerFactoryBean em = new LocalContainerEntityManagerFactoryBean();
    em.setDataSource(dataSource);
    em.setJpaPropertyMap(jpaProperties().getHibernateProperties(dataSource));
    em.setPackagesToScan("gov.ca.cwds.data.persistence.auth", "gov.ca.cwds.data.auth");
    em.setPersistenceUnitName("default");
    em.setJpaVendorAdapter(jpaVendorAdapter());
    return em;
}
Also used : LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean) Autowired(org.springframework.beans.factory.annotation.Autowired) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean) LocalContainerEntityManagerFactoryBean(org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean)

Aggregations

Primary (org.springframework.context.annotation.Primary)93 Bean (org.springframework.context.annotation.Bean)90 DruidDataSource (com.alibaba.druid.pool.DruidDataSource)15 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