Currently, We are creating a spring boot project for our newer modules.
Technology We have used as follows :
- Java 1.8
- Maven 3.5.2
- Spring Boot: 1.5.6.RELEASE (spring-boot-starter-parent)
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
@Autowired
private DataSource datasource;
}
application.properties
- spring.datasource.url=jdbc:oracle:XXX:@XXX:XXX/XXX
- spring.datasource.username=XXX
- spring.datasource.password=XXX
- spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
application.yml
spring:
- profiles:
- active: "dev"
- main:
- banner-mode: "off"
spring:
- profiles: dev
- datasource:
- url:jdbc:oracle:XXX:@XXX:XXX/XXX
- username:XXX
- password:XXX
- driver-class-name:oracle.jdbc.driver.OracleDriver
When we are adding data source information as properties file the application working as expected. But information as YAML means showing below error.
ERROR
Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'testapplication': Unsatisfied dependency expressed through field '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/DataSourceConfiguration$Tomcat.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.tomcat.jdbc.pool.DataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it (the profiles "dev" are currently active).
driver-class-name:oracle.jdbc.driver.OracleDriver
? If not that is wrong. You need to have a space after colon according to yml convention – pvpkiran