I have a Configuration.class, which fetches properties from application.properties
.
@Component
public class Configuration {
@Value("${someValue}")
public String someValue;
}
I have another class called Fetcher
, which needs the property.
class Fetcher {
@Autowired
private Configuration configuration;
public void doSomethingWithSomeValue() {
System.out.println(configuration.someValue);
}
}
Of course the above code would fail because Fetcher
is not a Spring Bean(I didn't add @Component
/@Service
/@Repository
to it). My question is, is it possible to get someValue
in Fetcher
without making it a Spring Bean?