在spring xml配置中定义guava HashBasedTable/Table [英] Define guava HashBasedTable/Table in spring xml config
本文介绍了在spring xml配置中定义guava HashBasedTable/Table的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在spring xml配置文件中创建并填充一个番石榴HashBasedTable
,但我一直无法这样做.
I'm trying to create and populate a guava HashBasedTable
in spring xml config file but I haven't been able to.
我的桌子看起来像这样:
My table looks like this:
Table<String, Foo, Bar> myTable;
我已经在xml中尝试过此操作,但是不知道如何将新值放入表中
And I've tried this in my xml but don't know how put new value into the table:
<property name="myTable">
<bean class="com.google.common.collect.HashBasedTable" factory-method="create">
<!--- how do I insert value in here??? -->
</bean>
</property>
推荐答案
如果只想在xml中执行此操作,则有些棘手:我看到guava没有提供太多选项来将值放入该表中. 有一种方法,但是对于多个插入来说很奇怪:
If you want to do this exclusively in xml, it's a bit tricky: I see guava doesn't offer too many options for putting values in that Table. There is an approach, but it's weird for more than one insert:
<bean id="myTable" class="com.google.common.collect.HashBasedTable" factory-method="create" />
<bean class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
<property name="targetObject">
<ref local="myTable" />
</property>
<property name="targetMethod">
<value>put</value>
</property>
<property name="arguments">
<list>
<value>1</value>
<value>1</value>
<value>value</value>
</list>
</property>
</bean>
这篇关于在spring xml配置中定义guava HashBasedTable/Table的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文