How to set Spring boot property with underscore in its name through environment variables?

I want to install hibernate.format_sqlSpring downloads in an application. I want to set it using environment variables.

Spring Boot pretty conveniently converts all environment variables from, for example, FOO_BAR_BAZto properties called foo.bar.bazinside the Spring context.

How to set underscore property in target name in Spring Boot using environment variables? Supposedly to HIBERNATE_FORMAT_SQLbe translated into hibernate.format.sql?

+4
source share
2 answers

, , - (, ) , .

HIBERNATE_FORMAT_SQL

, "", Spring.

. . "hibernate.format.sql" :

  • hibernate.format.sql( )
  • hibernate_format_sql ( )
  • hibernate_format_sql ( , )
  • hibernate_format_sql ( , )

UPPERCASE:

  1. HIBERNATE.FORMAT.SQL( )
  2. HIBERNATE_FORMAT_SQL ( )
  3. HIBERNATE_FORMAT_SQL ( , )
  4. HIBERNATE_FORMAT_SQL ( , )

​​ set export, env. , :

env "my.dotted.name=\"a value\"" the-command-you-want-to-run

SystemEnvironmentPropertySource.java . , , .

, :

logging:
  level:
    org.springframework.core.env: DEBUG

... :)

+7

SPRING_JPA_SHOW_SQL=true . , , , Spring - . , .

0

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


All Articles