模块启动器不会将app.view导出到模块tornadofx

时间:2019-12-11 16:15:47

标签: kotlin tornadofx

我试图显示一个带有Tornadofx框架的窗口,但是每当我尝试运行我的代码时,都会遇到这些错误(即使当我运行由朋友编写的在他们计算机上工作的程序时)

Caused by: java.lang.IllegalAccessException: class tornadofx.FXKt (in module tornadofx) cannot access class app.view.HelloWorld (in module Launcher) because module Launcher does not export app.view to module tornadofx
at java.base/jdk.internal.reflect.Reflection.newIllegalAccessException(Reflection.java:376)
at java.base/java.lang.reflect.AccessibleObject.checkAccess(AccessibleObject.java:642)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:490)
at java.base/java.lang.reflect.ReflectAccess.newInstance(ReflectAccess.java:166)
at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(ReflectionFactory.java:404)
at java.base/java.lang.Class.newInstance(Class.java:591)
at tornadofx@1.7.19/tornadofx.FXKt.find(FX.kt:436)
at tornadofx@1.7.19/tornadofx.FXKt.find$default(FX.kt:425)
at tornadofx@1.7.19/tornadofx.App.stop(App.kt:138)
at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$10(LauncherImpl.java:865)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:455)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:428)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:427)
at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
at javafx.graphics/com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at javafx.graphics/com.sun.glass.ui.win.WinApplication.lambda$runLoop$3(WinApplication.java:174)
... 1 more

这是我的代码:


import app.view.HelloWorld
import tornadofx.*

class Launcher: App(HelloWorld::class)

package app.view

import javafx.beans.property.SimpleStringProperty
import tornadofx.*
import app.controller.HelloWorldController

class HelloWorld: View() {
    val controller: HelloWorldController by inject()
    val input = SimpleStringProperty()

    override val root = form {
        fieldset {
            field("Input") {
                textfield(input)
            }

            button("Commit") {
                action {
                    controller.writeToDb(input.value)
                    input.value = ""
                }
            }
        }
    }
}```

0 个答案:

没有答案