在 Netbeans 平台中,我让一个模块监视 xml 文件系统,并在其他模块更改它时做出响应。
我在另一个模块中创建了一个layer.xml。当我在观察模块中单击 XML 层节点并打开时,更改会显示在 IDE 中。然而,在运行时,当监视模块查看 xml 文件系统时,其他模块的更改不存在。另一个模块可以在运行时看到自己的变化。
某个模块是否有一个设置可以让其他模块看到它的 xml 层?
这是我用来在运行时检查 xml 文件系统的代码 - 它将所有节点的名称打印到文件中,当所有模块打开并运行时,我通过按钮触发它。
private void btn1ActionPerformed(java.awt.event.ActionEvent evt)
{
try {
BufferedWriter writer = Files.newBufferedWriter(Paths.get("filesystemOut.txt"), Charset.forName("UTF-8"));
exportFilesystem(FileUtil.getConfigRoot(), writer, 0);
writer.close();
} catch (IOException e) {
System.err.println("couldn't write filesystem structure");
}
}
void exportFilesystem(FileObject root, BufferedWriter writer, int depth) throws IOException
{
for (int i = 0; i < depth * 4; ++i)
{
writer.write(' ');
}
writer.write(root.getName());
writer.newLine();
FileObject[] children = root.getChildren();
for (FileObject child : children)
{
exportFilesystem(child, writer, depth + 1);
}
}
最佳答案
打开包含需要可见的 xml 层的模块的属性对话框。选择API 版本控制
,然后在公共(public)包
下选择包含 xml 文件的包。单击确定
。
关于java - 使模块的 xml 层对其他模块可见,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25772317/