jeudi 13 août 2015

Autowiring of a java List in Spring

I have the following Bean which I would like to have autowired in another class:

@Scope("job")
@Component
public class PublicCompanyHolder {

private List<File> publicCompanyList;

public List<File> getPublicCompanyList() {
return publicCompanyList;
}

public void setPublicCompanyList(List<File> publicCompanyList) {
this.publicCompanyList = publicCompanyList;
}

}

My Spring config looks like :

 <bean id="publicCompanyHolder" class="com.sample.bean.PublicCompanyHolder" >   
        <property name="publicCompanyList" ref="publicCompanyList" />
     </bean>
      <bean id="publicCompanyList" class="java.util.List" />

Is this the right way to do it.In another class by simply saying:

@Autowired
    private PublicCompanyHolder publicCompanyHolder;

I would like to use the class.Please let me know.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire