I'm a developper and I start with SpringBoot to make an application. I follow a course in udemy. I have problem when I try to run application.This is error description in console :
APPLICATION FAILED TO START
Description:
CurrencyConfigurationService is annotated with @ConstructorBinding but it is defined as a regular bean which caused dependency injection to fail.
Action:
Update your configuration so that CurrencyConfigurationService is defined via @ConfigurationPropertiesScan or @EnableConfigurationProperties.
Process finished with exit code 0
and this is the content of my Class CurrencyConfigurationService
package spring.boot.learnspringboot.services;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
@ConfigurationProperties(prefix = "currency-service")
@Component
public class CurrencyConfigurationService {
private String url;
private String username;
private String key;
public CurrencyConfigurationService(String url, String username, String key) {
this.url = url;
this.username = username;
this.key = key;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
}
Someone can help me to debug this problem?
I try to make an application using SpringBoot, it's the start with springboot for me and I have a problem that I am no idea to solve it
To fix it you have to do some changes:
CurrencyConfigurationService:
Main class:
And I think your
application.yml
file are as following one:Or if it is
application.properties
file