From PHP I am used to just saving the .php
file and reloading the browser after modifying the source file. How can I do this with JAVA and Jetty? When I save my webservice I currently stop the jetty server and start it again with mvn jetty:start
, whats the non-complicated way of getting where I want to go?
From the command line:
mvn -Djetty.reload=automatic -Djetty.scanIntervalSeconds=2 jetty:run
If you are depending on Eclipse, ensure you have Project->Build Automatically enabled so that the classes are recompiled.
I haven't tried the configuration file approach, but more details of Jack Murphy's approach can be found here: http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin
Well, the difference between PHP and Java is that the former is an interpreter, whereas the latter is compiler-based (binary). In PHP the code is validated upon execution, whereas in Java you need to compile it first. In Java, when you use JSP-s, it is possible to just save them and reload them by hitting the refresh button in your browser (if, of course, it's running in development mode). If you change classes, you need to restart your server. If your're just changing web resources, you can simply define the scanInterval
variable for the Jetty Maven plugin. That will takes care of updating your web resources.
[EDITED] Added the code from Jack Murphy's comment below, so that it is correctly formatted.
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<configuration>
<scanIntervalSeconds>2</scanIntervalSeconds>
</configuration>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With