在 Wicket 中重新加载代码更改

发布于 2024-10-07 17:30:36 字数 537 浏览 6 评论 0原文

我已经开始使用 Wicket。当我对 HTML 模板进行更改时,它会立即变得可见。

但是当我更改代码时,我需要重新启动 Jetty。我正在 DEVELOPMENT 模式下运行(至少日志中的大胖警告是这么说的),并且我已经按照这个问题安装了 ReloadingWicketFilterWicket - 运行时类重新加载

我的猜测是,这种行为是因为我在页面的构造函数中进行了所有更改,并且当我重新加载时,Wicket 不会创建新页面。

我浏览过 Wicket 示例,但没有示例展示如何构建 Wicket 页面而无需在构造函数中添加所有组件,或者如何告诉 Wicket 为每个请求创建一个新页面,或者如何告诉 Wicket 创建一个新页面。

I've started to work with Wicket. When I make changes to the HTML templates, that becomes visible right away.

But when I make changes to the code, I need to restart Jetty. I'm running in DEVELOPMENT mode (at least that's what the big fat warning in the log says) and I have installed the ReloadingWicketFilter as per this question: Wicket - runtime class reloading

My guess is that this behavior is because I make all changes in the constructor of my pages and Wicket doesn't create a new page when I reload.

I've browsed the Wicket examples but there is no example which shows how to build a Wicket page without adding all components in the constructor or how to tell Wicket to create a new page for every request or how to tell Wicket to create a new Page.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

静水深流 2024-10-14 17:30:36

我正在使用 mvn jetty:run 并在 pom.xml 中使用此配置:

 <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <!-- to be used in combination with netbeans compile on save feature -->
                <scanTargets>
                    <scanTarget>target/classes/</scanTarget>
                </scanTargets>
                <scanIntervalSeconds>1</scanIntervalSeconds>
            </configuration>
 </plugin>

并且我的 IDE (NetBeans) 配置为在保存时进行编译...然后我可以更改切换到浏览器并点击重新加载...然后更改已应用 + jetty 已重新加载

或使用商业应用程序 jrebel

I am using mvn jetty:run and this config in the pom.xml:

 <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <!-- to be used in combination with netbeans compile on save feature -->
                <scanTargets>
                    <scanTarget>target/classes/</scanTarget>
                </scanTargets>
                <scanIntervalSeconds>1</scanIntervalSeconds>
            </configuration>
 </plugin>

And my IDE (NetBeans) is configured that it compiles on save... then I can make a change switch to the browser and hit reload ... and the changes were applied + jetty was reloaded

Or use the commercial app jrebel

笑红尘 2024-10-14 17:30:36

我认为最后一段可以通过重写 Component 的 onInitialize() 方法来解决。

请参阅http://wicket.apache。 org/apidocs/1.4/org/apache/wicket/Component.html#onInitialize()

问候,

马雷克

I think that last paragraph can be addressed by overriding Component's onInitialize() method.

See http://wicket.apache.org/apidocs/1.4/org/apache/wicket/Component.html#onInitialize()

Regards,

Marek

好倦 2024-10-14 17:30:36

在 IntelliJ 中,通过调试运行 Start 应用程序。当您对 Java 进行更改并进行编译时,IntelliJ 会通过 HotSpot 重新加载该类。这些更改将在您的应用程序中可用。

当然,您会受到 HotSpot 的限制,即只能(例如)创建新类和更改方法体。

In IntelliJ, run the Start application through debugging. As you make changes to Java and compile, IntelliJ reloads the class through HotSpot. The changes become available in your application.

You are of course limited to HotSpot"s limitation of only being able to (for example) create new classes and change method bodies.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文