7.springboot configuration file Configuration Run environment, drop location

Source: Internet
Author: User

1.properties mode

Dev Test prod developing and testing production environment data

Multi-profile file

Default Application.properties

You can switch the environment:

Spring.profiles.active=dev

2.YML mode

YML supports multi-document block environments

YAML uses---to "split" a document into multiple documents

#yaml文档块模式server:   8081 Spring:  profiles:  activemq:dev---server:  8083Spring:  Profiles: Dev---server:  8084Spring:  profiles:prod

3 How to modify the command line in real time:

--spring.profiles.active=prod

You can do it, don't write it wrong.

Or package, go to the Jar package directory, cmd command line startup Project command is the following:

Java-jar Spring-boot-02-config-0.0.1-snapshot.jar--spring.profiles.active=prod

  

Or use the virtual machine parameters

-dspring.profiles.active=dev

Configuration file Drop Location

Scan: The config directory under the current project file:/config/, the file path of the current project file:./, the config inside the classpath classpath:/config/, the root directory of the classpath classpath:/

Scan in sequence with priority high to low, duplicate configuration is overwritten by high priority, non-duplicated configuration complements

As below, the Classpath under config is higher than./Medium priority

The Config directory has the highest priority under the project path

When the following method is only applicable to operations, you can use command line arguments to specify a new location for the configuration file that complements the default profile.

Spring.config.location=g:\application.properties

  

The command line can also be teminal in the lower left corner of the portal, suitable for operations when a small number of new configurations are added without repackaging in the run project

7.springboot configuration file Configuration Run environment, drop location

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.