Spring-Path的工厂方法 [英] Spring - factory method for Path

查看:103
本文介绍了Spring-Path的工厂方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用静态方法Paths.get(String path)生成一个表示java.nio.file.Path的bean.我当前的Spring设置如下:

I am trying to generate a bean that would represent java.nio.file.Path using a static method Paths.get(String path). my current Spring setup looks as follows:

<bean id="myPath" class="java.nio.file.Paths" factory-method="get">
    <constructor-arg value="c:\\tmp\\" />
</bean>

,但返回时带有No matching factory method found: factory method 'get'.知道为什么会这样吗?

but it comes back with an excpetion No matching factory method found: factory method 'get'. Any ideas why that is the case?

推荐答案

java.nio.file.Paths.get需要URI.此外,这是xml而不是Java,请不要使用\\

java.nio.file.Paths.get expects URI. Besides, this is xml not java don't use \\

尝试为

file:/C:/tmp/

如果您对URI语法有疑问,请访问 http://en.wikipedia.org/wiki/File_url

If you have problems with URI syntax visit http://en.wikipedia.org/wiki/File_url

这篇关于Spring-Path的工厂方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆