NullPointerException可能是空的
ApplicationProperties。
所有自定义属性都应加注解
@ConfigurationProperties(prefix="custom")。之后,必须在您的主类(具有main方法的类)上添加
@EnableConfigurationProperties(CustomProperties.class)。对于自动完成,您可以使用:
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-configuration-processor</artifactId> <optional>true</optional></dependency>
如果使用
@ConfigurationProperties不带前缀,则仅使用字段名称。您的属性中的字段名称。就您而言
path-mapper,接下来您具体
key和
value。例:
path-mapper.key=value
在更改自己的属性后,请记住您需要重新加载应用程序。例:
https://github.com/kchrusciel/SpringPropertiesExample



