I have small test project to test Spring annotations:
where in nejake.properties
is:
klucik = hodnoticka
and in App.java
is:
@Configuration
@PropertySource("classpath:/com/ektyn/springProperties/nejake.properties")
public class App
{
@Value("${klucik}")
private String klc;
public static void main(String[] args)
{
AnnotationConfigApplicationContext ctx1 = new AnnotationConfigApplicationContext();
ctx1.register(App.class);
ctx1.refresh();
//
App app = new App();
app.printIt();
}
private void printIt()
{
System.out.println(klc);
}
}
It should print hodnoticka
on console, but prints null
- String value is not initialized. My code is bad - at the moment I have no experience with annotation driven Spring. What's bad with code above?