Java tutorial
package org.activiti; import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.util.StringUtils; import javax.sql.DataSource; /** * Short description text. * <p/> * Long detailed description text for the specific class file. * * @author Vladimir Nikolaenko <dev@caple.co> * @version 10/19/2015 * @see 2015 Caple International B.V. - All Rights Reserved * See LICENSE file or http://caple.co for further details */ @Configuration public class DatabaseConfiguration { @Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource() { HikariConfig config = new HikariConfig(); config.setDataSourceClassName("org.postgresql.ds.PGSimpleDataSource"); if (StringUtils.isEmpty("")) { config.addDataSourceProperty("databaseName", "caple-test2"); config.addDataSourceProperty("serverName", "localhost"); } else { config.addDataSourceProperty("url", ""); } config.addDataSourceProperty("user", "postgres"); config.addDataSourceProperty("password", "123"); return new HikariDataSource(config); } }