I am using Spring Boot 1.3, and I have the configuration class below:
@Configuration
public class MainConfig {
@Bean(name="dateAndTimeFormater")
public SimpleDateFormat dateAndTimeFormater(){
return new SimpleDateFormat("yyyy-MM-dd"+Constants.STRING_SEPARATOR+"hh:mm");
}
@Bean(name="dateFormater")
public SimpleDateFormat dateFormaterBean(){
return new SimpleDateFormat("yyyy-MM-dd"+Constants.STRING_SEPARATOR+"hh:mm");
}
}
When I try to inject one of the below beans by name, it throws : No qualifying bean of type [java.text.SimpleDateFormat] is defined: expected single matching bean but found 2: dateAndTimeFormater,dateFormater.
here is where I am injecting the bean: private static SimpleDateFormat sdf;
@Autowired
@Qualifier("dateAndTimeFormater")
public static void setSdf(SimpleDateFormat sdf) {
myClass.sdf = sdf;
}
I tried with @Ressource, @Inject. it didn't work.
Any Advise will be much appreciated?