We use hierarchically organised Spring boot property files in our application. For example,
Our application.properties will just contain a single line.
spring.profiles.include = logging, kafka, oracle, misc
Where all the values separated by comma here are other property files (namely application-logging.properties and so on) that it's referring to (We chose this for reusability in different environments)
And I have another properties file application-h2.properties that can be included while testing. So while I test, my application.properties will look like this.
spring.profiles.include = logging, kafka, h2, misc
The problem that's been bugging me here is that my application is always considering h2 database when it starts up, although I include oracle.
Here's how my application-oracle.properties file looks.
spring.datasource.url=${ORACLE_URL}
spring.datasource.username=${ORACLE_USERNAME}
spring.datasource.password=${ORACLE_PASSWORD}
spring.jpa.show-sql=true
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
spring.jpa.properties.hibernate.jdbc.time_zone = UTC
The only way I have to get Oracle enabled is that I have remove the h2 properties file, and also remove the h2 dependency from the gradle build file.
Appreciate your help!
Did you try changing the h2 dependency scope? Changing the scope to test worked for me.