当前位置: 首页>>代码示例>>Java>>正文


Java DataSourceBuilder.url方法代码示例

本文整理汇总了Java中org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder.url方法的典型用法代码示例。如果您正苦于以下问题:Java DataSourceBuilder.url方法的具体用法?Java DataSourceBuilder.url怎么用?Java DataSourceBuilder.url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder的用法示例。


在下文中一共展示了DataSourceBuilder.url方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Primary
@Bean(destroyMethod = "close")
public DataSource dataSource() {
    final EmbeddedMysql embeddedMysql = embeddedMysql(); // make sure embeddedMySql is started.

    Map<String, String> params = ImmutableMap.<String, String>builder()
            .put("profileSQL", String.valueOf(false))
            .put("generateSimpleParameterMetadata", String.valueOf(true))
            .build();

    final String url = String.format("jdbc:mysql://localhost:%d/%s?%s",
            embeddedMysql.getConfig().getPort(),
            SCHEMA_NAME,
            Joiner.on("&").withKeyValueSeparator("=").join(params));

    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.username(embeddedMysql.getConfig().getUsername());
    dataSourceBuilder.password(embeddedMysql.getConfig().getPassword());
    dataSourceBuilder.driverClassName(com.mysql.jdbc.Driver.class.getName());
    dataSourceBuilder.url(url);
    return dataSourceBuilder.build();
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:23,代码来源:EmbeddedMySqlConfig.java

示例2: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Bean
@Primary
public DataSource dataSource() {
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.driverClassName(org.sqlite.JDBC.class.getName());
    dataSourceBuilder.url("jdbc:sqlite:~amv-access-test.db?journal_mode=wal");
    return dataSourceBuilder.build();
}
 
开发者ID:amvnetworks,项目名称:amv-access-api-poc,代码行数:9,代码来源:SqliteTestDatabaseConfig.java

示例3: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的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

示例4: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Bean
public DataSource dataSource() {
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.driverClassName(driverClassName);
    dataSourceBuilder.url(url);
    dataSourceBuilder.type(HikariDataSource.class);
    return dataSourceBuilder.build();
}
 
开发者ID:Coding,项目名称:WebIDE-Backend,代码行数:9,代码来源:JpaConfig.java

示例5: buildDataSourceDev

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Bean
@Qualifier("dataSource")
public DataSource buildDataSourceDev() {
    DataSourceBuilder dsb = DataSourceBuilder.create();
    dsb.driverClassName(driver);
    dsb.url(url);
    dsb.username(username);
    dsb.password(password);
    return dsb.build();
}
 
开发者ID:belchan,项目名称:imageboard,代码行数:11,代码来源:ConfigDataSource.java

示例6: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Override
public DataSource dataSource() {
    log.info("Running with STAGING profile");
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.url(System.getenv("DATABASE_URL"));
    return dataSourceBuilder.build();
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:8,代码来源:StagingDatabaseConfig.java

示例7: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Override
public DataSource dataSource() {
    log.info("Running with LOCAL_PG profile");
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.url(env.getProperty("DATABASE_URL"));
    return dataSourceBuilder.build();
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:8,代码来源:StandaloneLocalPGConfig.java

示例8: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
@Override
public DataSource dataSource() {
    DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
    dataSourceBuilder.url(System.getenv("DATABASE_URL"));
    return dataSourceBuilder.build();
}
 
开发者ID:grassrootza,项目名称:grassroot-platform,代码行数:7,代码来源:ProductionDatabaseConfig.java

示例9: dataSource

import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder; //导入方法依赖的package包/类
/***************************************************************************************************** 
* Openshift - MySQL
*****************************************************************************************************
MySQL 5.5 database added.  Please make note of these credentials:

       Root User: adminCUBivEk
   Root Password: b4be_AuNYSPh
   Database Name: bruxelas

Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/

You can manage your new MySQL database by also embedding phpmyadmin.
The phpmyadmin username and password will be the same as the MySQL credentials above.	
	
***************************************************************************************************** 
* Openshift - PhpMyAdmin
*****************************************************************************************************
Please make note of these MySQL credentials again:
  Root User: adminCUBivEk
  Root Password: b4be_AuNYSPh
URL: https://bruxelas-fabianoggoes.rhcloud.com/phpmyadmin/
*****************************************************************************************************/
	
  @Bean(destroyMethod = "close")
  public DataSource dataSource() {
  	System.out.println( "<<< Profile = prod >>>" );

  	String host = System.getenv().get("OPENSHIFT_MYSQL_DB_HOST") == null ? "localhost" : System.getenv().get("OPENSHIFT_MYSQL_DB_HOST");
String port = System.getenv().get("OPENSHIFT_MYSQL_DB_PORT") == null ? "3306" : System.getenv().get("OPENSHIFT_MYSQL_DB_PORT");
String user = System.getenv().get("OPENSHIFT_MYSQL_DB_USERNAME") == null ? "bruxelas" : System.getenv().get("OPENSHIFT_MYSQL_DB_USERNAME");
String pass = System.getenv().get("OPENSHIFT_MYSQL_DB_PASSWORD") == null ? "bruxelas" : System.getenv().get("OPENSHIFT_MYSQL_DB_PASSWORD");

String database = "bruxelas";
String url = "jdbc:mysql://" + host + ":" + port + "/" + database + "?autoReconnect=true&useSSL=false";
DataSourceBuilder dataSourceBuilder = DataSourceBuilder.create();
dataSourceBuilder.url(url);
dataSourceBuilder.username(user);
dataSourceBuilder.password(pass);
return dataSourceBuilder.build();
  }
 
开发者ID:fabianogoes,项目名称:bruxelas,代码行数:41,代码来源:JPAConfigurationProd.java


注:本文中的org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder.url方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。