If you develop your applications you want super fast round trips. Deploying you application to an application server and waiting a long time until stuff is ready is just not productive.
On the other hand there is already seemingly good solution: the jetty-maven-plugin and the jetty:run goal.
Unfortunately jetty-maven-plugin and its jetty:run goal often leads to PermGen exceptions that block your JVM and cause nasty interruptions to productivity.
Therefore we developed Ninja's SuperDevMode. SuperDevMode does not suffer any PermGen exceptions and picks up any changes in your code really fast.
In any case you need an IDE that compiles your classes when you change them. NetBeans' “compile on save” works, Eclipse's “build automatically” feature works, but potentially any IDE out there will compile your Java files when you save them.
The flow is as follows: You start Ninja's SuperDevMode in a console. Then you edit a Java file in your IDE and save it. Your IDE will then compile your Java file to a class file. Ninja's SuperDevMode recognizes that and restarts Ninja within a second. You can then switch to your browser and verify that your changes work at http://localhost:8080 .
Rinse and repeat.
##Configuration
If you created your application from one of our recent archetypes you are already ready to go.
If not add the following plugin to your pom.xml file:
<plugin> <groupId>org.ninjaframework</groupId> <artifactId>ninja-maven-plugin</artifactId> <version>${ninja.version}</version> </plugin>
You can then call:
mvn ninja:run
And have a damn fast hot-reload code server running.
An example configuration looks like:
<plugin> <groupId>org.ninjaframework</groupId> <artifactId>ninja-maven-plugin</artifactId> <version>${project.version}</version> <configuration> <useDefaultExcludes>true</useDefaultExcludes> <excludes> <exclude>(.*)png$</exclude> </excludes> <context>/your_context_path</context> </configuration> </plugin>
You can configure the plugin via the following parameters:
Can be true or false. Ninja's SuperDevMode will not restart when you make changes inside templates (ftl.html) or your assets directory. These changes will be picked up anyway by Ninja in devmode. But there might be cases were you want Ninja to restart. Then simply set useDefaultExcludes to false.
If you want to tell Ninja's SuperDevMode that it should no pick up changes of certain files or patterns you can define that by the parameter excludes.
In the example above no file ending in “png” will cause a reload. You can use Java regular expressions to specify the files.
Allows you to add a context prefix to your application ("" by default). The
old name of this property contextPath
is still supported, while context
will supercede it if set. If the option is omitted you can provide it by
system property:
mvn ninja:run -Dninja.context=/your_context_path
Allows you to set a custom port when running SuperDevMode (8080 default). If the option is omitted you can provide it by system property:
mvn ninja:run -Dninja.port=YourPortNumber
Allows you to set any sort of argument you would like to passthru to the forked Ninja JVM in SuperDevMode.
mvn ninja:run -Dninja.jvmArgs="-Dninja.host=localhost -Djavax.net.debug=all"
Allows you to set the main class that SuperDevMode will run. Defaults to Ninja
default standalone class which is ninja.standalone.NinjaJetty
.
mvn ninja:run -Dninja.mainClass="com.example.MyClass"