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