How do I make these warnings go away?
gateway:
servers:
- url: https://localhost:8080
description: Dynamic-Gateway
versionPrefix: /api/v1
publicPatterns:
- /api/v1/registration/**
- /api/v1/login/**
- /actuator/**
- /swagger-ui/**
- /webjars/**
- /doc/*
ignoredPatterns:
- /error/**
The properties are accessed from my @ConfigurationProperties
file fine, but those warnings just get on my nerves
@Component
@ConfigurationProperties(prefix = "gateway")
@Setter
public final class GatewayMeta {
private List<Server> servers;
private String versionPrefix;
private String[] publicPatterns;
private String[] ignoredPatterns;
public List<Server> servers() {
return this.servers;
}
public String versionPrefix() {
return this.versionPrefix;
}
public String[] publicPatterns() {
return this.publicPatterns;
}
public String[] ignoredPatterns() {
return this.ignoredPatterns;
}
}
Baeldung suggested adding this dependency
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
I added it, reloaded the project, nothing changed
Before you close it as a duplicate, I want you to know that I checked these five similar questions: 1, 2, 3, 4, 5
For the most part, they weren't answered, but one person suggested switching to properties
. I don't want to
One guy said in the comments that I should
Add the YAML file to the Spring Context configuration manually
and linked this page. It simply says to navigate to your installed pugins and ensure that all Spring-related ones are checked. They are
I can suppress, though. If I put it in my yml
, the warnings go away. But it feels like a hack
#file: noinspection SpringBootApplicationYaml
How am I supposed to avoid such warnings?
Java 17. Spring Boot 3.2.1. Ultimate IntelliJ 2022.3.2
Changing servers()
to getServers()
should nudge IntelliJ in the right direction.
See Naming convention for getters/setters in Java for more details on getters/setters conventions in Java (or JavaBeans to be more precise).
By the way, I see that you're using Lombok's @Setter
- adding @Getter
(either on class or on fields) should also resolve the error.