我为我的spring项目创建了一个带有配置属性的简单类。除了Eclipse在application.yml中不承认新属性为有效选项之外,一切都是有魅力的(spring捕捉选项),并将其突出显示为未知属性。
这是一堂课:
@Component
@ConfigurationProperties(prefix="server")
public class ServerProperties {
private Integer delay;
private DataAdapter dataAdapter = new DataAdapter();
// setters and getters were cut out for the sake of readability
public static class DataAdapter {
private String baseUrl;
private String targetCode;
// setters and getters
}
}“自动完成”不适用于下列属性:

我按照pom.xml的建议将Spring配置处理器的依赖项添加到Spring.io参考中,但它不像设想的那样工作。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>尝试切换到application.properties,但是自动完成仍然不能工作。
发布于 2019-04-13 01:08:14
Spring引导配置处理器在编译期间充当注释处理器。
有必要为Eclipse项目启用注释处理并注册处理器:

发布于 2019-10-15 09:47:57
我也遇到了同样的问题,并通过将以下内容添加到我的pom.xml中来解决:
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>https://stackoverflow.com/questions/55661132
复制相似问题