I have a value stored in an application.properties file in the resources directory. I want to inject this value in a class with the @Configuration annotation.
@Configuration
@RequiredArgsConstructor
public class Xconfig {
@Value("${x}")
private final String x;
}
application.properties:
x=hello
This works for @Component/@Service classes but not for the @Configuration. Error message:
Parameter 1 of constructor in xConfig required a bean of type 'java.lang.String' that could not be found.
finalfromString x, or declare your constructor manually (and remove@RequiredArgsConstructor) and attach @Value to the parameter. - mrkernelpanic