I have an application.yml that works and is being used when connecting to the database:
spring:
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://10.100.247.112:5432/ofbizBuchhandel
username: buchhandel
password: buchhandel
When I add an environment profile to the configuration:
spring:
profiles: development
datasource:
driverClassName: org.postgresql.Driver
url: jdbc:postgresql://10.100.247.112:5432/ofbizBuchhandel
username: buchhandel
password: buchhandel
I'm getting this error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'demoApplication': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.example.DbAccess com.example.DemoApplication.dbd; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dbAccess': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: org.springframework.jdbc.core.JdbcTemplate com.example.DbAccess.jdbcTemplate; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.sql.DataSource org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$JdbcTemplateConfiguration.dataSource; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration$NonEmbeddedConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
From my understanding here http://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-change-configuration-depending-on-the-environment the setting for profiles looks correct.