SpringBoot: configuring Vs configuration for development

I have a problem with SpringBoot 1.5.1. I created application.propertiesand application-dev.propertiesfor my development environment.

The main difference is in persistence: in production ( application.properties) there is JNDI (configured on Tomcat), and in dev there is local db (H2).

This is my conf in application.properties:

spring.datasource.jndi-name=jdbc/db

And this application-dev.properties:

spring.datasource.url=jdbc:h2:file:~/db
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.driverClassName=org.h2.Driver

But when I start with the dev profile

2017-02-24 15:25:39.948  INFO 7912 --- [           main] it.geny.MmqApplication                   : The following profiles are active: dev

my application stops because it did not find jndi jdbc / db !!!! I am trying to change the log configuration on mine application-dev.propertiesand it works! But not changes in persistence configuration.

Thanks in advance

+4
source share
1 answer

application-dev.properties application.properties. application.properties , dev, . spring.datasource.jndi-name , spring.datasource .

, , application-prod.properties, spring.datasource.jndi-name. application-dev.properties.

application.properties , : spring.profiles.active=prod spring.profiles.active=dev

+7

Source: https://habr.com/ru/post/1670755/


All Articles