7

I'm trying to use the application.properties file to configure the datasource Spring Boot will have to use.

I've put the following properties inside :

spring.datasource.driverClassName=org.postgresql.Driver
spring.datasource.user=test
spring.datasource.password=test
spring.datasource.jdbcUrl=jdbc:postgresql://localhost:5432/test

The application.properties file is well used by other systems. But I can't get it to work for the automatic datasource configuration.

I'm still getting this Exception :

org.springframework.beans.factory.BeanCreationException: Cannot determine embedded database url for database type NONE.

The postgresql driver is included and loaded. And I can configure the datasource using a Configuration class, and the same parameters as above.

I've also added the @EnableAutoConfiguration and @EnableJpaRepositories to my Application.class.

Any clues?

2
  • 1
    Do you have one of the supported DataSource implementations on the classpath (e.g. Tomcat JDBC)?
    – Dave Syer
    Nov 27, 2014 at 17:35
  • Yes I have them. When I manually configure the datasource it works like a charm.
    – mrik974
    Nov 28, 2014 at 7:36

1 Answer 1

22

You should use spring.datasource.url to configure the JDBC URL rather than spring.datasource.jdbcUrl.

spring.datasource.jdbcUrl will work if the specific DataSource implementation that you're using has a setJdbcUrl method (HikariCP, for example) where as spring.datasource.url will work with any of the supported datasources.

Using spring.datasource.url also has the added benefit that you don't need to specify spring.datasource.driverClassName as it will be inferred from the url.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.