我在我的 spring 配置文件中提供以下定义:
<bean id="path" class="java.nio.file.Paths" factory-method="get">
<constructor-arg>
<value type="java.lang.String">${limits.path}</value>
</constructor-arg>
</bean>
Paths.get
可以使用字符串参数或 URI 参数调用。 SPring,在上面的示例中将其解析为 URI,这是错误的...知道为什么吗?
最佳答案
尝试使用特定索引,它可能有问题,因为它在方法签名中有一个可变参数。
来自神谕docs :
get(String first, String... more)
尝试这样的事情:
<bean id="path" class="java.nio.file.Paths" factory-method="get">
<constructor-arg index="0"
type="java.lang.String"
value="${limits.path}" />
</bean>
如果不起作用,请尝试使用空列表:
<bean id="path" class="java.nio.file.Paths" factory-method="get">
<constructor-arg index="0">
<value type="java.lang.String">${limits.path}</value>
</constructor-arg>
<constructor-arg index="1">
<list></list>
</constructor-arg>
</bean>
关于java - Spring - 调用了错误的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14201602/