Search in sources :

Example 36 with Primary

use of org.springframework.context.annotation.Primary in project xm-ms-entity by xm-online.

the class XmAuthContextHolderDefaultTestConfiguration method xmAuthenticationContextHolder.

@Bean
@Primary
public XmAuthenticationContextHolder xmAuthenticationContextHolder() {
    XmAuthenticationContext context = mock(XmAuthenticationContext.class);
    when(context.hasAuthentication()).thenReturn(true);
    when(context.getLogin()).thenReturn(Optional.of("testLogin"));
    when(context.getUserKey()).thenReturn(Optional.of("ACCOUNT.TEST"));
    XmAuthenticationContextHolder holder = mock(XmAuthenticationContextHolder.class);
    when(holder.getContext()).thenReturn(context);
    return holder;
}
Also used : XmAuthenticationContext(com.icthh.xm.commons.security.XmAuthenticationContext) XmAuthenticationContextHolder(com.icthh.xm.commons.security.XmAuthenticationContextHolder) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 37 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 38 with Primary

use of org.springframework.context.annotation.Primary in project hub-alert by blackducksoftware.

the class DatabaseDataSource method jpaTransactionManager.

@Bean
@Primary
public JpaTransactionManager jpaTransactionManager(DataSource dataSource) {
    JpaTransactionManager transactionManager = new JpaTransactionManager();
    transactionManager.setDataSource(dataSource);
    return transactionManager;
}
Also used : JpaTransactionManager(org.springframework.orm.jpa.JpaTransactionManager) Primary(org.springframework.context.annotation.Primary) Bean(org.springframework.context.annotation.Bean)

Example 39 with Primary

use of org.springframework.context.annotation.Primary in project mybatis.flying by limeng32.

the class SqlSessionFactoryConfig method createSqlSessionFactoryBean.

@Bean(name = "sqlSessionFactory")
@Primary
public SqlSessionFactoryBean createSqlSessionFactoryBean() throws IOException {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    /**
     * 设置datasource
     */
    sqlSessionFactoryBean.setDataSource(dataSource1);
    VFS.addImplClass(SpringBootVFS.class);
    /**
     * 设置mybatis configuration 扫描路径
     */
    sqlSessionFactoryBean.setConfigLocation(new ClassPathResource("Configuration.xml"));
    /**
     * 设置typeAlias 包扫描路径
     */
    sqlSessionFactoryBean.setTypeAliasesPackage("indi.mybatis.flying");
    /**
     * 添加mapper 扫描路径
     */
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    Resource[] ra1 = resolver.getResources("classpath*:indi/mybatis/flying/mapper*/*.xml");
    // 扫描映射文件
    sqlSessionFactoryBean.setMapperLocations(ra1);
    return sqlSessionFactoryBean;
}
Also used : ClassPathResource(org.springframework.core.io.ClassPathResource) Resource(org.springframework.core.io.Resource) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) PathMatchingResourcePatternResolver(org.springframework.core.io.support.PathMatchingResourcePatternResolver) ClassPathResource(org.springframework.core.io.ClassPathResource) Primary(org.springframework.context.annotation.Primary) SqlSessionFactoryBean(org.mybatis.spring.SqlSessionFactoryBean) Bean(org.springframework.context.annotation.Bean)

Example 40 with Primary

use of org.springframework.context.annotation.Primary in project summer by foxsugar.

the class WechatPayConfig method wxPayService.

@Bean(name = "wxPayService")
@Primary
public WxPayService wxPayService() {
    WxPayService wxPayService = new WxPayServiceImpl();
    wxPayService.setConfig(wxPayConfig());
    return wxPayService;
}
Also used : WxPayService(com.github.binarywang.wxpay.service.WxPayService) WxPayServiceImpl(com.github.binarywang.wxpay.service.impl.WxPayServiceImpl) Primary(org.springframework.context.annotation.Primary) 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