By default, SpringApplication converts any command line option arguments (that is, arguments starting with --, such as --server.port=9000) to a propertyand adds them to the Spring Environment. As mentioned previously, command line properties always take precedence over other property sources.
If you do not want command line properties to be added to the Environment, you can disable them by using SpringApplication.setAddCommandLineProperties(false).
解释一下:通过--server.port=9000这种形式传入参数,如果不想设置到环境变量Environment中可以通过以下操作处理:
SpringApplication.setAddCommandLineProperties(false)
网友评论