I create a bean with annotations.
@Component public class MyClass { @Autowired private ArrayList<String> myFriends= new ArrayList<String>();
I get the following exception
Failed to create autowire field: private java.util.ArrayList com.mypackage.MyClass.myFriends; The nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: no bean match found for type [java.util.ArrayList] for the dependency: at least 1 bean is expected that qualifies as an auto-connect candidate for this dependency. Dependency Annotations: {@ org.springframework.beans.factory.annotation.Autowired (required = true)}
I also tried with this
@Resource private ArrayList<String> myFriends= new ArrayList<String>();
I get the following exception
No bean mapping found for the type [java.util.ArrayList] found for the dependency: at least 1 bean is expected to qualify as an autwire candidate for this dependency. Dependency Annotations: {@ javax.annotation.Resource (shareable = true, mappedName =, description =, name =, type = class java.lang.Object, authenticationType = CONTAINER)}
Please let me know how to fix this.
source share