8

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)? Commented Nov 27, 2014 at 17:35
  • Yes I have them. When I manually configure the datasource it works like a charm. Commented Nov 28, 2014 at 7:36

1 Answer 1

23

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Spring jpa 2+ uses hicari connection pool by default so this property doesn’t work anymore for pople who want to use a connection pool. Instead ‘spring.datasource.jdbc-url’ is the one which works.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.