9

我正在使用 NetBeans 6.8、Tomcat 6 和 Maven 2.2,并希望在保存文件后立即在浏览器中查看我的代码更改(显示http://localhost:8080)。

tomcat-maven-plugin 有以下配置:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>tomcat-maven-plugin</artifactId>
  <version>1.0-beta-1</version>
</plugin>

在输出之后,它应该执行就地部署。

如何在浏览器中立即查看 Java 代码的更改?

4

4 回答 4

1

看看JRebel。它应该做你想做的事。无痛。

于 2014-01-29T12:29:56.457 回答
0

I spent a lot of time trying to get this work. Finally I just used jetty. I put this:

   <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>jetty-maven-plugin</artifactId>
            <version>${jetty.version}</version>
            <configuration>
                <reload>automatic</reload>
                <scanIntervalSeconds>5</scanIntervalSeconds>
            </configuration>
   </plugin>

Maybe all parameters are not correct, but then I created a custom goal of 'jetty:run' And I use that. I can't use the big green play button 'Run', but the jetty deploy works nicely and it hot deploys any changes in the Java classes.

于 2010-08-04T22:30:02.777 回答
0

查看在 NetBeans 中使用 Maven 热部署 Web 应用程序。我还建议检查Glassfish Hot Code Re-deployment (on Maven),特别是关于 Compile on Save 的帖子,并尝试 GlassFish,您可能会得到更好的结果。

于 2010-05-03T08:44:57.123 回答
0

使用tomcat:inplace目标从其编译的类和源中调用您的 webapp。

您可能会在 Windows 上遇到文件锁定问题。有几种解决方法,例如antiJarLockingcontet 属性,但基本上这归结为您的 web 应用程序没有正确关闭,在几次重新加载后最终会耗尽您的 VM 内存。就我而言,我使用的是 Spring,“正确”的修复是在一些关键 bean 上添加一个销毁方法,以便应用程序正常关闭。

Maven Tomcat 插件 - tomcat:inplace

于 2010-05-03T08:46:36.167 回答