Spring Download 1.4: Set the default profile when deploying the application to Tomcat

I have a Spring Boot 1.4 application that has a YAML based configuration file. The configuration file indicates the default profile:prod

spring:
  profiles.active: prod

When I create a war using Maven and deploy it to Tomcat 7, the default profile is not set. Tomcat Magazine:

No active profile set, falling back to default profiles: default

To set the default profile in an application deployed to Tomcat, I can pass the System Tomcat property, for example:

-Dspring.profiles.active=prod

This works, but I would like to use the Spring Boot properties, not the System properties to set the default profile. Is there a reason why the yaml properties file is ignored by default when deploying the application to Tomcat?

+4
1

, :

    spring:
      profiles: development
      devtools:
        restart:
          enabled: false
      thymeleaf:
        mode: HTML
        cache: false
      http:
        multipart:
          max-file-size: 3Mb
          max-request-size: 4Mb

    logging:
      level:
        org.apache: WARN
        org.apache.catalina.webresources.Cache: ERROR
        org.hibernate: WARN
        org.hibernate.SQL: WARN
        org.hibernate.type: WARN
        org.hibernate.jpa.internal: ERROR
        org.springframework: WARN
        org.springframework.data.jpa: WARN
        org.springframework.validation: WARN
        org.springframework.web: WARN
        org.springframework.web.socket: WARN
        org.zkoss: WARN
        com.ultraip: TRACE

    ---

    spring:
      profiles: default
      thymeleaf:
        mode: HTML
      http:
        multipart:
          max-file-size: 3Mb
          max-request-size: 4Mb
      messages:
        cache-seconds: -1
      resources:
        cache-period: 259200

    server:
      port: 80
      session:
        timeout: 86400
      compression:
        enabled: true
        mime-types: "text/html,text/xml,text/css,text/plain,application/json,application/xml,application/javascript"

    security:
      headers:
        cache: false

    logging:
      file: "/var/log/intranet.log"
      level:
        org.apache: WARN
        org.apache.catalina.webresources.Cache: ERROR
        org.hibernate: WARN
        org.hibernate.jpa.internal: ERROR
        org.springframework: WARN
        org.zkoss: WARN
        com.ultraip: INFO

"---"

0

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


All Articles