erstellen der hashmap im Frühjahr

Ich bin erstellen einer bean ist der Frühling wie folgt

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

wenn ich diese ausführe bekomme ich den Fehler wie folgt:

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)

Ich nicht wollen, zu erstellen hasmp mit aufgrund irgendeinem anderen Grund.

  • kann ${somehashMapPaceholder} nur Punkt-zu-String? oder kann es irgendwann andere hashmap ? ${somehashMapPaceholder} ist eine Referenz zu einigen anderen hashmap in meinem Fall
  • Könnten Sie uns ein vollständigeres Beispiel, vor allem, wo kommt ${somehashMapPaceholder} kommen, und was ist der Inhalt? Warum nutzen Sie nicht die ref-statt Wert?
  • es somes von einigen dort zu platzieren gibt es einige depedency, dass es tut.Aber ich bin mir nicht sicher, ob ${somehashMapPaceholder} können Sie einen Verweis zu einer anderen Karte? Kann ein Platzhalter, zeigen Sie auf einige andere Karte?
  • kann u bitte helfen Sie mir mit diesem
  • Sie können ref Attribut verweisen auf eine andere bean in den Kontext.
  • ich nicht erstellen, dass die Bohne.Dass es automatisch verfügbar als ich eine andere lib.
  • Es gibt keine solche Sache wie automatisch zur Verfügung. Bitte zeigen Sie genau das, was du meinst.
  • meine Anwendung arbeitet innerhalb eines Containers, die hat einige komplexe Aufgaben. Nun, wenn ich solche Platzhalter für string funktioniert es.Aber für die ap auch nicht. ich werde versuchen, mit <constructor-arg ref="{Platzhalter} /> .

InformationsquelleAutor user93796 | 2013-09-28
Schreibe einen Kommentar