当我尝试使用编组和解组时,我得到“无法从编译器访问org.exolab.castor.core.exceptions.CastorException”“。我使用Castor 1.3
try {
Writer writer = new FileWriter("out.xml");
Marshaller.marshal(person, writer);
Reader reader = new FileReader("out.xml");
metaType = (Person) Unmarshaller.unmarshal(Person.class, reader);
}catch (MarshalException e) {
} catch (ValidationException e) {
}发布于 2010-01-02 21:48:29
首先,这不是一个异常,这是一个编译错误。代码甚至不能成为可运行的.class文件。这是一个巨大的差异。在未来,您应该尝试更明确地说明这一点。
这个编译错误实际上意味着在编译期间类路径中缺少提到的类。如果使用javac进行编译,则需要将Castor JAR文件的完整路径添加到-cp (类路径)参数中。如下所示:
javac -cp .;c:/path/to/Castor.jar com/example/YourClass.java这是一个Windows的例子;在Unix/Linux和clones中,你需要:作为路径分隔符。内部有空格的各个路径应该用引号括起来。
https://stackoverflow.com/questions/1991558
复制相似问题