Spring Applicationlistener with-D implementation parameter initialization

Source: Internet
Author: User

Applicationlistener is a springboot listener that provides four types of events:
    • Applicationstartedevent:spring the event that is executed when boot starts
    • The applicationenvironmentpreparedevent:spring boot corresponds to enviroment is ready, but the contextual context has not yet been created.
    • Applicationpreparedevent:spring Boot Context Context creation is complete, but at this point the bean in spring is not fully loaded.
    • Applicationfailedevent:spring Boot Exception Execution event

Therefore, we can implement this interface to initialize our custom parameters at the moment of system startup. Case scenario: The configuration file in the project is generally out-of-the-box, spring boot uses the Yml file, the project does not want to yml files into the jar package, but in the project to specify YML all directories that directory address and yml file name, when the system starts, through the Java-jar The Project jar package-dxxxx Specifies that these parameters (dynamic entry parameters), if not specified, use the default path and file name **********************************java-dkey=value: Set the property name/value pair in the system properties of the virtual machine. The system is available for applications running on this virtual machine. GetProperty ("key") gets the value ofReference: HTTPS://WWW.JIANSHU.COM/P/52F4BF5DD00F

Spring Applicationlistener with-D implementation parameter initialization

Related Article

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.