Is there a way to @Autowire a bean that requires constructor arguments?

You need the @Value annotation. A common use case is to assign default field values using “#{systemProperties.myProp}” style expressions. public class SimpleMovieLister { private MovieFinder movieFinder; private String defaultLocale; @Autowired public void configure(MovieFinder movieFinder, @Value(“#{ systemProperties[‘user.region’] }”) String defaultLocale) { this.movieFinder = movieFinder; this.defaultLocale = defaultLocale; } // … } See: Expression Language > Annotation … Read more

Populating Spring @Value during Unit Test

If possible I would try to write those test without Spring Context. If you create this class in your test without spring, then you have full control over its fields. To set the @value field you can use Springs ReflectionTestUtils – it has a method setField to set private fields. @see JavaDoc: ReflectionTestUtils.setField(java.lang.Object, java.lang.String, java.lang.Object)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)