Spring - factory method for Path

余生长醉 提交于 2019-12-23 09:23:28

问题


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>

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


回答1:


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

Try as

file:/C:/tmp/

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



来源:https://stackoverflow.com/questions/13680584/spring-factory-method-for-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!