为什么 mvn gluonfx:nativerun 时找不到 Gluon 控件 CardPane?

问题描述 投票:0回答:2

这是 FXML 文件:

<?import com.gluonhq.charm.glisten.control.CardPane?>
<?import com.gluonhq.charm.glisten.mvc.View?>
<?import javafx.scene.layout.BorderPane?>

<View fx:id="myView" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="600.0" prefWidth="335.0" xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.mydomain.view.MyPresenter">
   <center>
      <BorderPane prefHeight="591.0" prefWidth="322.0" BorderPane.alignment="CENTER">
         <center>
            <CardPane fx:id="cardPane" prefHeight="465.0" prefWidth="333.0" />
         </center>
      </BorderPane>
   </center>
</View>

如果我

mvn gluonfx:run
那么它就可以正常工作。我看到了卡片窗格。我可以向其中添加卡片。我看到它按预期更新了卡片列表。

但是如果我随后尝试

mvn gluonfx:nativerun
我会失败并出现 ClassNotFoundException: com.gluonhq.charm.glisten.control.CardPane

这是命令行调用堆栈的摘录:

Caused by: javafx.fxml.LoadException: 
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB] com/mydomain/view/myView.fxml
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB] 
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.constructLoadException(FXMLLoader.java:2707)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2949)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.processImport(FXMLLoader.java:2793)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.processProcessingInstruction(FXMLLoader.java:2758)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2624)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2548)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.load(FXMLLoader.java:2516)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at com.airhacks.afterburner.views.FXMLView.loadSynchronously(FXMLView.java:91)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  ... 21 more
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB] Caused by: java.lang.ClassNotFoundException: com.gluonhq.charm.glisten.control.CardPane
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:71)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at java.lang.ClassLoader.loadClass(ClassLoader.java:212)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.loadTypeForPackage(FXMLLoader.java:3017)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.loadType(FXMLLoader.java:3006)
[Wed Jul 21 09:59:25 MST 2021][INFO] [SUB]  at javafx.fxml.FXMLLoader.importClass(FXMLLoader.java:2947)
gluon
2个回答
0
投票

感谢@JoséPereda 提醒我下一步该去哪里。一路上出现了新问题,但我最终让应用程序在本机运行模式下运行。

但是,我随后意识到了我的菜鸟错误。我忘记继续回到项目pom文件来更新gluon插件的reflectionList。因此,我用底层配置文件取消了混乱的修复,然后按如下方式更新。我根据我看到的堆栈跟踪反馈向您展示了我需要提及的平台小部件。我还列出了我自己的课程,但也不必费心在此处显示这些课程。

            <artifactId>gluonfx-maven-plugin</artifactId>
            <version>${gluonfx.plugin.version}</version>
            <configuration>
                <reflectionList>
                    <list>javafx.scene.control.DatePicker</list>
                    <list>com.gluonhq.charm.glisten.control.CardPane</list>

0
投票

添加到 Javateer,也许只需将所有导入添加到反射列表中即可:

                    <reflectionList>
                        <list>javafx.scene.control.ListView</list>
                        <list>javafx.scene.control.SplitPane</list>
                        <list>javafx.scene.control.ButtonBar</list>
                        <list>javafx.scene.layout.AnchorPane</list>
                        <list>javafx.scene.layout.ColumnConstraints</list>
                        <list>javafx.scene.layout.GridPane</list>
                        <list>javafx.scene.layout.HBox</list>
                        <list>javafx.scene.control.Menu</list>
                        <list>javafx.scene.control.MenuBar</list>
<!--                        <list>javafx.scene.control.MenuItem</list>-->
                        <list>javafx.scene.layout.RowConstraints</list>
                        <list>org.travelonline.guidemo.persongui.FXApplication</list>
                        <list>org.travelonline.guidemo.persongui.FXController</list>
                    </reflectionList>

基于我在下面的 fxml 文件中的导入:

    <?import javafx.scene.control.Button?>
    <?import javafx.scene.control.Label?>
    <?import javafx.scene.control.ListView?>
    <?import javafx.scene.control.Menu?>
    <?import javafx.scene.control.MenuBar?>
    <?import javafx.scene.control.MenuItem?>
    <?import javafx.scene.control.SplitPane?>
    <?import javafx.scene.control.TextArea?>
    <?import javafx.scene.control.TextField?>
    <?import javafx.scene.control.ButtonBar?>
    <?import javafx.scene.layout.AnchorPane?>
    <?import javafx.scene.layout.ColumnConstraints?>
    <?import javafx.scene.layout.GridPane?>
    <?import javafx.scene.layout.HBox?>
    <?import javafx.scene.layout.RowConstraints?>

© www.soinside.com 2019 - 2024. All rights reserved.