Oleg Shankovskyi Oleg Shankovskyi - 1 month ago 44
Java Question

Problems with defining profiles in pom.xml (Spring Boot)

I have a Spring Boot application with two profiles: 'dev' and 'prod'. In 'dev' profile should be used H2 database, in 'prod' — PostgreSQL.

They are defined in pom.xml as following:





No other databases are in pom.xml defined.

In my application.properties file 'prod' profile is defined as active:

spring.profiles.active = prod

Also I have two specific properties files for each profile:


spring.jpa.show-sql = true

and application-prod.properties (I deploy my app to AWS):

spring.datasource.url = jdbc:postgresql://${RDS_HOSTNAME}:${RDS_PORT}/${RDS_DB_NAME}
spring.datasource.username = ${RDS_USERNAME}
spring.datasource.password = ${RDS_PASSWORD}
spring.jpa.hibernate.ddl-auto = update

I start my IntelliJ IDEA with following VM-option:


When I start the program locally, I see that 'dev' profile is used (there is message in console "The following profiles are active: dev"), but H2 doesn't start. I become following error message:



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).

Please help me to define these profiles correctly.


Cannot determine embedded database driver class for database type NONE

spring.datasource.url = jdbc:h2:mem:yourDB
spring.datasource.driverClassName = org.h2.Driver

added in application-dev.properties file should solve your problem.


Maven profile is not Spring Boot profile.
when you run your project, enable also the maven profile with -P arg:

  mvn spring-boot:run -Pdev -Dspring.profiles.active="dev"