0

I'm working on a web based application with Spring boot and Oracle 11g. The application is split to 4 Maven Modules which are:

Model - in which are declared all Entities. Persistence - in which i have Spring data's repositories. Domain - in which i have All services. Web - in which i have MVC.

So in my persistence project I have application.properties which looks like this:

spring.data.jpa.repositories.enabled=true

spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=create
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.Oracle10gDialect

spring.datasource.url=jdbc:oracle:thin:@//localhost:1521/xe
spring.datasource.username=MOVIE_CATALOG
spring.datasource.password=MOVIE_CATALOG
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver

If the database is created it works fine but if the database is not created and i expect Hibernate to do this for me I receive an exception like this:

Caused by: 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 (no profiles are currently active).

I find out that if I put database configuration in Web's application.properties the project work fine too but I don't want to do this.

Any ideas why this exception occurred?

Tunaki
  • 132,869
  • 46
  • 340
  • 423
Petar Petrov
  • 586
  • 2
  • 10
  • 28
  • What does your folder structure look like? I'm wondering where your application.properties file is. – kevingreen Feb 21 '17 at 20:16
  • 1
    I have 2 application.properties. The first one is in Persistence where i want to define database configuration. The second one is in web where i want to define web configuration like server.port and others. The both files are in src/main/resources – Petar Petrov Feb 21 '17 at 20:36

2 Answers2

1

Hibernate can auto create tables, but not a whole data base. Create an empty database for Hibernate to build the tables.

Similar StackOverflow question

Spring Documentation Only mentions creating and dropping tables.

Community
  • 1
  • 1
kevingreen
  • 1,541
  • 2
  • 18
  • 40
  • I have schema in Oracle which is called MOVIE_CATALOG but when I start application hibernate does not create tables, sequences and indexes. So i do not expect hibernete to create the whole database. Just tables, sequence and indexes – Petar Petrov Feb 21 '17 at 20:39
  • @PetarPetrov Hmm. I'll keep thinking on it. If I have an idea, I'll post it. – kevingreen Feb 21 '17 at 21:01
1

If you're booting your application from Web then the local application.properties file replaces the one in Persistence, as opposed to merging.

A Solution would be to rename one of the files and specify them both in @PropertySource on your @Configuration classes.

AlyoshaKaramazov
  • 616
  • 1
  • 9
  • 25