我正在编写一个在Java中运行xjc的类。我的代码如下:
URL url = new URL("C:\\Users\\Simran\\Desktop\\books.xsd");
SchemaCompiler sc = XJC.createSchemaCompiler();
sc.parseSchema(new InputSource(url.toExternalForm()));
S2JJAXBModel model = sc.bind();
JCodeModel cm = model.generateCode(null, null);
cm.build(new FileCodeWriter(new File("C:\\Users\\Simran\\Desktop\\books.xsd")));
但是当我运行这个代码时,出现了以下错误:
Exception in thread "main" java.net.MalformedURLException: no protocol: books.xsd
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at jaxbTest.Test1.main(Test1.java:22)
请问有谁能帮忙解决这个问题吗?
sc.parseSchema(new InputSource("C:\\Users\\Simran\\Desktop\\books.xsd"));
吗? - jmj