當前位置: 首頁>>代碼示例>>Java>>正文


Java Primary類代碼示例

本文整理匯總了Java中org.springframework.context.annotation.Primary的典型用法代碼示例。如果您正苦於以下問題:Java Primary類的具體用法?Java Primary怎麽用?Java Primary使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Primary類屬於org.springframework.context.annotation包,在下文中一共展示了Primary類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: businessSqlSessionFactory

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public SqlSessionFactory businessSqlSessionFactory(@Qualifier("businessDataSource") DruidDataSource businessDataSource) throws Exception {
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(businessDataSource);
    //mybatis分頁
    Properties props = new Properties();
    props.setProperty("dialect", "mysql");
    props.setProperty("reasonable", "true");
    props.setProperty("supportMethodsArguments", "true");
    props.setProperty("returnPageInfo", "check");
    props.setProperty("params", "count=countSql");
    PageHelper pageHelper = new PageHelper();
    pageHelper.setProperties(props);
    //添加插件
    sqlSessionFactoryBean.setPlugins(new Interceptor[]{pageHelper});
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources(MAPPERXML_LOCATION));
    return sqlSessionFactoryBean.getObject();
}
 
開發者ID:DomKing,項目名稱:springbootWeb,代碼行數:21,代碼來源:BusinessDatabaseConfig.java

示例2: jGitRepository

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
@SneakyThrows
public JGitRepository jGitRepository(ApplicationProperties applicationProperties, HazelcastInstance hazelcastInstance) {

    return new JGitRepository(applicationProperties.getGit(), new ReentrantLock()) {
        @Override
        protected void initRepository(){};
        @Override
        protected void pull(){};
        @Override
        protected void commitAndPush(String commitMsg){};
        @Override
        public List<com.icthh.xm.ms.configuration.domain.Configuration> findAll(){
            return emptyList();
        }
    };
}
 
開發者ID:xm-online,項目名稱:xm-ms-config,代碼行數:19,代碼來源:TestConfiguration.java

示例3: mafMasterDataSource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean(name = ConfigConstant.NAME_DS_MASTER)
@Primary
@ConfigurationProperties(prefix = ConfigConstant.PREFIX_DS_MASTER)
public DataSource mafMasterDataSource() {
    logger.info("----- MAFIA master data source INIT -----");
    DruidDataSource ds = new DruidDataSource();
    try {
        ds.setFilters(env.getProperty("ds.filters"));
    } catch (SQLException e) {
        logger.warn("Data source set filters ERROR:", e);
    }
    ds.setMaxActive(NumberUtils.toInt(env.getProperty("ds.maxActive"), 90));
    ds.setInitialSize(NumberUtils.toInt(env.getProperty("ds.initialSize"), 10));
    ds.setMaxWait(NumberUtils.toInt(env.getProperty("ds.maxWait"), 60000));
    ds.setMinIdle(NumberUtils.toInt(env.getProperty("ds.minIdle"), 1));
    ds.setTimeBetweenEvictionRunsMillis(NumberUtils.toInt(env.getProperty("ds.timeBetweenEvictionRunsMillis"), 60000));
    ds.setMinEvictableIdleTimeMillis(NumberUtils.toInt(env.getProperty("ds.minEvictableIdleTimeMillis"), 300000));
    ds.setValidationQuery(env.getProperty("ds.validationQuery"));
    ds.setTestWhileIdle(BooleanUtils.toBoolean(env.getProperty("ds.testWhileIdle")));
    ds.setTestOnBorrow(BooleanUtils.toBoolean(env.getProperty("ds.testOnBorrow")));
    ds.setTestOnReturn(BooleanUtils.toBoolean(env.getProperty("ds.testOnReturn")));
    ds.setPoolPreparedStatements(BooleanUtils.toBoolean(env.getProperty("ds.poolPreparedStatements")));
    ds.setMaxOpenPreparedStatements(NumberUtils.toInt(env.getProperty("ds.maxOpenPreparedStatements"), 20));
    return ds;
}
 
開發者ID:slking1987,項目名稱:mafia,代碼行數:26,代碼來源:DsMasterConfig.java

示例4: hazelcastInstance

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public HazelcastInstance hazelcastInstance(JHipsterProperties jHipsterProperties) {
    log.debug("Configuring Hazelcast");
    HazelcastInstance hazelCastInstance = Hazelcast.getHazelcastInstanceByName("gate");
    if (hazelCastInstance != null) {
        log.debug("Hazelcast already initialized");
        return hazelCastInstance;
    }
    Config config = new Config();
    config.setInstanceName("gate");
    config.getNetworkConfig().setPort(5701);
    config.getNetworkConfig().setPortAutoIncrement(true);

    // In development, remove multicast auto-configuration
    if (env.acceptsProfiles(JHipsterConstants.SPRING_PROFILE_DEVELOPMENT)) {
        System.setProperty("hazelcast.local.localAddress", "127.0.0.1");

        config.getNetworkConfig().getJoin().getAwsConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        config.getNetworkConfig().getJoin().getTcpIpConfig().setEnabled(false);
    }
    config.getMapConfigs().put("default", initializeDefaultMapConfig());
    config.getMapConfigs().put("com.icthh.xm.gate.domain.*", initializeDomainMapConfig(jHipsterProperties));
    return Hazelcast.newHazelcastInstance(config);
}
 
開發者ID:xm-online,項目名稱:xm-gate,代碼行數:27,代碼來源:CacheConfiguration.java

示例5: getDataSource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public DataSource getDataSource() {
    HikariConfig config = new HikariConfig();
    config.setDriverClassName("com.mysql.jdbc.Driver");
    config.setJdbcUrl("jdbc:mysql://localhost:3306/test");
    config.setUsername("root");
    config.setPassword("root");
    config.setMaximumPoolSize(500);
    config.setMinimumIdle(10);
    return new HikariDataSource(config);
}
 
開發者ID:SkywalkingTest,項目名稱:Agent-Benchmarks,代碼行數:13,代碼來源:DataSourceConfiguration.java

示例6: oauth2RemoteResource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@ConfigurationProperties(prefix = "security.oauth2.client")
@Primary
public ClientCredentialsResourceDetails oauth2RemoteResource() {
	ClientCredentialsResourceDetails details = new ClientCredentialsResourceDetails();
	return details;
}
 
開發者ID:spring-projects,項目名稱:spring-security-oauth2-boot,代碼行數:8,代碼來源:OAuth2RestOperationsConfiguration.java

示例7: getDataSource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@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;
}
 
開發者ID:apache,項目名稱:nifi-registry,代碼行數:33,代碼來源:DataSourceFactory.java

示例8: mafMasterSqlSessionFactory

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean(name = ConfigConstant.NAME_DS_SSF_MASTER)
@Primary
public SqlSessionFactory mafMasterSqlSessionFactory(@Qualifier(ConfigConstant.NAME_DS_MASTER) DataSource mafMasterDataSource) throws Exception {
    logger.info("----- MAFIA master data source sql session factory INIT -----");
    final SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
    sessionFactory.setDataSource(mafMasterDataSource);
    sessionFactory.setConfigLocation(new ClassPathResource(ConfigConstant.NAME_MYBATIS_CONFIG));
    return sessionFactory.getObject();
}
 
開發者ID:slking1987,項目名稱:mafia,代碼行數:10,代碼來源:DsMasterConfig.java

示例9: getDatasource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
/**
 * Get data source.
 *
 * @return Data source
 */
@Primary
@Bean
@ConfigurationProperties(prefix="spring.datasource")
public DataSource getDatasource() {
    return DataSourceBuilder.create().build();
}
 
開發者ID:JonkiPro,項目名稱:REST-Web-Services,代碼行數:12,代碼來源:WebDatasourceConfig.java

示例10: loadProperties

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public Properties loadProperties() throws FileNotFoundException, IOException {
	String propsLocation = System.getProperty("properties.location");
	Properties props = new Properties();
	props.load(new FileReader(new File(propsLocation)));
	return props;
}
 
開發者ID:qzagarese,項目名稱:dockerunit,代碼行數:9,代碼來源:AppRunner.java

示例11: writeDataSource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
/**
 * 主庫配置(負責寫)
 * @return
 */
@Bean(name="masterDataSource")
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource writeDataSource() {
    log.info("-------------------- Master DataSource init ---------------------");
    return DataSourceBuilder.create().type(dataSourceType).build();
}
 
開發者ID:MIYAOW,項目名稱:MI-S,代碼行數:12,代碼來源:DataBaseConfiguration.java

示例12: masterDataSource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean(name = "masterDataSource")
@Primary
public DataSource masterDataSource() {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(driverClass);
    dataSource.setUrl(url);
    dataSource.setUsername(user);
    dataSource.setPassword(password);
    return dataSource;
}
 
開發者ID:zcc225,項目名稱:springboot-copy,代碼行數:11,代碼來源:MasterDataSourceConfig.java

示例13: objectMapper

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public ObjectMapper objectMapper() {
    return new ObjectMapper()
        .registerModule(new Jdk8Module())
        .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES))
        .registerModule(new JavaTimeModule()).disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS)
        .setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
        .disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
}
 
開發者ID:hmcts,項目名稱:cmc-claim-store,代碼行數:11,代碼來源:JacksonConfiguration.java

示例14: tokenServices

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public DefaultTokenServices tokenServices() {
    final DefaultTokenServices defaultTokenServices = new DefaultTokenServices();
    defaultTokenServices.setTokenStore(tokenStore());
    defaultTokenServices.setSupportRefreshToken(true);
    return defaultTokenServices;
}
 
開發者ID:PacktPublishing,項目名稱:Building-Web-Apps-with-Spring-5-and-Angular,代碼行數:9,代碼來源:AuthServerOAuth2Config.java

示例15: dataSource

import org.springframework.context.annotation.Primary; //導入依賴的package包/類
@Bean
@Primary
public DataSource dataSource() {
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.driverClassName(org.sqlite.JDBC.class.getName());
    dataSourceBuilder.url("jdbc:sqlite:~amv-access-swagger-docs.db?journal_mode=wal");
    return dataSourceBuilder.build();
}
 
開發者ID:amvnetworks,項目名稱:amv-access-api-poc,代碼行數:9,代碼來源:SwaggerSqliteTestDatabaseConfig.java


注:本文中的org.springframework.context.annotation.Primary類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。