Spring yaml 环境无法与数据源协同工作

Spring yaml environment not working together with datasource

我有一个 application.yml 可以工作并且在连接到数据库时正在使用:

spring:
 datasource:
  driverClassName: org.postgresql.Driver
  url: jdbc:postgresql://10.100.247.112:5432/ofbizBuchhandel
  username: buchhandel
  password: buchhandel

当我将环境配置文件添加到配置时:

spring:
 profiles: development
 datasource:
  driverClassName: org.postgresql.Driver
  url: jdbc:postgresql://10.100.247.112:5432/ofbizBuchhandel
  username: buchhandel
  password: buchhandel

我收到这个错误:

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.

根据我的理解http://docs.spring.io/spring-boot/docs/current/reference/html/howto-properties-and-configuration.html#howto-change-configuration-depending-on-the-environment配置文件的设置看起来是正确的。

正确答案是我打错了:(