Spring Boot uses MAVEN package to delete configuration files

Source: Internet
Author: User

The Spring Boot Project uses MAVEN packaging
    • Project conditions:
    1. *.properties is placed outside the jar package to make it convenient for dynamic real-time configuration information
    2. *.properties is not allowed to exist inside the jar package (it is actually config that takes precedence over the configuration file in the jar package)
    3. Dynamically specifying the build environment and configuration files (in-Service architecture design)

Solutions

    1. Project Server jar package in the same directory, create a new config folder, directly nohup boot
    2. MAVEN Package Culling *.properties

      # build下配置<resources><resource><filtering>true</filtering><directory>src/main/resources/</directory><excludes><exclude>application.properties</exclude></excludes></resource></resources>#includes包含#excludes不包含#更多需要配置的可以看maven官网
    3. Dynamically specifying the build environment and configuration files (in-Service architecture design)

      # test是我的测试环境spring.profiles.active=test
    • After configuring the configuration file to get outside the jar, the project will start at 8080 Port when running in idea, preferably with 1 and 2, if the project does not require that the *.properties file within the jar package be rejected, this step is not required.

The GitHub address is attached later:

Spring Boot uses MAVEN package to delete configuration files

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.