[英]Xtext error: Registered resource factory is needed
I have an application that accepts a file as an input. 我有一个接受文件作为输入的应用程序。 Since the files are located in different location, the path will be relative to the .jar location.
由于文件位于不同的位置,因此路径将相对于.jar位置。
Example: D:\\Test\\JAVA_App\\Exe is where that tester.jar is placed. 示例:D:\\ Test \\ JAVA_App \\ Exe是放置tester.jar的位置。 So when ran in the windows command line, I do this: tester.jar D:\\Test\\JAVA_App\\Exe....\\testcase1.txt
所以当在Windows命令行中运行时,我这样做:tester.jar D:\\ Test \\ JAVA_App \\ Exe .... \\ testcase1.txt
To process the file, my code is calling ResourceSet from org.eclipse.emf.ecore.resource.ResourceSet. 为了处理文件,我的代码从org.eclipse.emf.ecore.resource.ResourceSet调用ResourceSet。 This is the code I have:
这是我的代码:
ResourceSet set = resourceSetProvider.get()
Resource resource = set.getResource(URI.createURI(<inputted path of file>))
I found out that the "registered resource factory is needed" error is not caused by an incorrect path (I can open it if I run the whole path in the commandline), but because of the "..\\" in between. 我发现“需要注册的资源工厂”错误不是由错误的路径引起的(如果我在命令行中运行整个路径,我可以打开它),但是因为它们之间的“.. \\”。 If I use "....\\testcase1.txt" only, it works fine.
如果我只使用“.... \\ testcase1.txt”,它可以正常工作。 But if it has the "D:\\" in the beginning with "..\\" in between, the error occurs.
但如果它的开头有“D:\\”,中间有“.. \\”,则会发生错误。
Is there another way to use "D:\\Test\\JAVA_App\\Exe....\\testcase1.txt" in xtext? 还有另一种方法在xtext中使用“D:\\ Test \\ JAVA_App \\ Exe .... \\ testcase1.txt”吗?
I guess that the D: is interpreted as a scheme. 我猜D:被解释为一个方案。 Try using 'URI.createFileURI()' instead.
请尝试使用'URI.createFileURI()'。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.