la création de hashmap au printemps

Je suis entrain de créer un bean est le printemps comme suit

<bean id="xyz" class ="java.util.HashMap">
  <constructor-arg  value ="${somehashMapPaceholder}"
</bean>

lorsque je l'exécute j'obtiens l'erreur suivante:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'personToDept' defined in class path resource [spring-configuration/application/appconfig-beans.xml]: Could not resolve matching constructor (hint: specify index/type/name arguments for simple parameters to avoid type ambiguities)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:250)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1035)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:939)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:225)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:291)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:193)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:607)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:925)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:472)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)

Je ne veux pas créer hasmp l'aide pour une autre raison.

  • peut ${somehashMapPaceholder} seul point à la Chaîne? ou peut-il point quelque autre table de hachage ? ${somehashMapPaceholder} est une referance à certains autres hashmap dans mon cas
  • Pourriez-vous nous donner un exemple plus complet, en particulier là où ne ${somehashMapPaceholder} viennent et quel est le contenu? Pourquoi n'utilisez-vous pas la réf au lieu de la valeur?
  • il somes de certains, il en place il y a quelques depedency qui le fait.Mais je suis pas sûr si ${somehashMapPaceholder} peut contenir une référence à une autre carte? Peut un espace réservé à un point à un autre de la carte?
  • peut-u s'il vous plaît m'aider avec ce
  • Vous pouvez utiliser ref attribut de se référer à un autre bean dans le contexte.
  • je ne créer que des haricots.Automatiquement ajoutés comme je l'ai utiliser une autre lib.
  • Il n'y a pas une telle chose comme automatiquement disponible. S'il vous plaît montrer exactement ce que vous voulez dire.
  • mon application fonctionne à l'intérieur d'un conteneur qui effectue des tâches complexes. Maintenant, si j'utilise un tel espace réservé pour la chaîne, il fonctionne.Mais pour l'ap de ses pas. je vais essayer d'utiliser <constructor-arg ref="{placholder} /> .

InformationsquelleAutor user93796 | 2013-09-28