The value located under your not.found
property is nothing more than String
, so you can perform any operations on that String.
(位于not.found
属性下的值not.found
是String
,因此您可以对该String执行任何操作。)
Eg. (例如。)
not.found = Employee with id %s not found
And process this message in your service however you desire.
(并根据需要在您的服务中处理此消息。)
throw new ResourceNotFoundException(String.format(env.getProperty("not.found"), employeeId));
Moreover you can access other properties and environment variables in your config.
(此外,您可以在配置中访问其他属性和环境变量。)
default.message = Exception occurred:
not.found = ${default.message} ${ENVIRONMENT_VARIABLE}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…