Spring boot different environments use different configurations

Source: Internet
Author: User

Spring boot enables you to use different configuration variables in different environments (such as development, test, and production environments) by configuring multiple profiles in the APPLICATION.YML configuration file.

The configuration is as follows (content in APPLICATION.YML):

Server:
  port:8082

# The default profile is dev, and other environments use different profiles by specifying startup parameters, such as:
#   test Environment: Java-jar My-spring-boot.jar--spring.profiles.active=test
#   production environment: Java-jar My-spring-boot.jar-- Spring.profiles.active=prod
Spring:
  profiles:
    active:dev

---
# development environment Configuration
Spring:
  Profiles:dev
MySQL:
  ipport:localhost:3306
  
---
# test environment Configuration
Spring:
  profiles:test
MySQL:
  ipport:192.168.0.12:8066
  
---
# production environment Configuration
Spring:
  profiles:prod
MySQL:
  ipport:192.168.0.13:8066

How to use:

Use different profiles by specifying the startup parameters, such as:
# test environment: Java-jar My-spring-boot.jar--spring.profiles.active=test
# production environment: Java-jar My-spring-boot.jar--spring.profiles.active=prod

Source code Address: Https://github.com/xujijun/my-spring-boot

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.