SpringBoot configure custom properties

foreword

Recently, I am working on a small program back-end interface service (the framework is Springboot). Some business information needs to be obtained by calling the interface of the third-party system. At this time, it is necessary to configure the URL of the access path of the third-party system. There are two ways: one It is written directly in the constant class, and the other is configured in the application.properties file. Personally, I prefer the second method. Let's introduce this method:

Step 1: Add configuration to application.properties:

#EMBC服务端地址
embc.service.url = http://192.168.18.179:9097/vcs

Step 2: Get the attribute value

@Value("${embc.service.url}")
public static String EMBC_REQUEST_HEAD;

Finish.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324517112&siteId=291194637