简体   繁体   English

Apache Pivot-BXML​​文件的位置

[英]Apache Pivot - location of the BXML file

I am using maven to build application and I would like to try out apache pivot for the GUI rendering. 我正在使用maven来构建应用程序,并且我想尝试用于apache透视的GUI渲染。 However, it looks like most pivot tutorials assume that you are using eclipse. 但是,似乎大多数数据透视教程都假定您正在使用Eclipse。 I added 2.0 version in my pom.xml (and tried with 2.0.2 as well), but, I get this error: 我在pom.xml中添加了2.0版本(并尝试了2.0.2版),但是,出现此错误:

[DEBUG] joining on thread Thread[Timer-1,5,com.polyglot.HelloBXML]
java.lang.IllegalArgumentException: location is null.
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:604)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:568)
at org.apache.pivot.beans.BXMLSerializer.readObject(BXMLSerializer.java:534)
at com.polyglot.HelloBXML.startup(HelloBXML.java:21)

It seems like it is unable to find the BXML file. 似乎无法找到BXML文件。 I had put it in src/main/resources. 我把它放在src / main / resources中。 I searched the forums and it looks like it is because BXML file is not in the classpath. 我搜索了论坛,看起来是因为BXML文件不在类路径中。 I tried with target/classes, but still no avail. 我尝试了目标/类,但还是没有用。 Can somebody guide me what is the correct location of the BXML file? 有人可以指导我BXML文件的正确位置是什么吗?

For the HelloBXML.java example 对于HelloBXML.java示例

change 更改

window = (Window)bxmlSerializer.readObject(HelloBXML.class, "hello.bxml");

to

window = (Window)bxmlSerializer.readObject(HelloBXML.class, "/hello.bxml");

and put hello.bxml in src/main/resources. 并将hello.bxml放在src / main / resources中。

(may need to be backslash for MS Windows environment, but I don't know) (对于MS Windows环境,可能需要反斜杠,但我不知道)

The solution to put it in the classpath was correct. 将其放在类路径中的解决方案是正确的。 I copied it in src/main/resources/{my package path} and it works. 我将其复制到src / main / resources / {我的包路径}中,并且可以正常工作。 My mistake was I was putting it in src/main/resources directly. 我的错误是我将其直接放在src / main / resources中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM