In the future, WildFly Swarm will be renamed Thorntail and aim for growth that is not bound by WildFly.
Until now, the development of the WildFly Swarm app has been difficult because it cannot handle hot reloads.
WildFly Swarm had no choice but to create a UberJar (executable JAR) and run it with the java -jar
command.
WildFly Swawrm's UberJAR can easily range from tens of megabytes to over 100 megabytes, taking time to package in development.
With the replacement of Thorntail, the Developer Tool is now available for hot reloading. (A mechanism that reloads only the changed class without packaging or redeploying the entire application while the application server is running)
Since I tried the function this time, I will write the execution procedure below along with the sample code.
At the time of this writing, Thorntail was only available in SNAPSHOT version and had not been released to Maven Central, so $ HOME / .m2 can be used to resolve dependencies on Thorntail's SNAPSHOT version libraries and plugins. Add
https://oss.sonatype.org/content/repositories/snapshots as a Snapshot repository to /settings.xml
.
xml:$HOME/.m2/settings.xml
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd" xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<profile>
<id>ossrh</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<repositories>
<repository>
<snapshots />
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<snapshots />
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
I have posted the sample code I made on GitHub. https://github.com/sightseeker/thorntail-demo
I will omit the procedure to create a project from scratch.
Sample code checkout
git clone [email protected]:sightseeker/thorntail-demo.git && cd thorntail-demo
Only one JAX-RS (REST API) is written in the source.
├── pom.xml
└── src
└── main
├── java
│ └── com
│ └── sightseekerstudio
│ ├── MyApplication.java
│ └── MyResource.java
└── resources
└── META-INF
├── application.properties
└── beans.xml
The following procedure uses two terminal windows. (For Thorntail execution (A) and for the compilation process (B))
Terminal A
#Initial build of app
mvn package
#Reload development mode and launch Thorntail
THORNTAIL_DEV_MODE=reload
./target/thorntail-demo-1.0-SNAPSHOT-bin/bin/run.sh
#The server log appears in the standard output
Access http: // localhost: 8080 with a browser etc. and confirm that Hello World
is displayed.
I'm using the Fizzed Watcher Maven Plugin to set pom.xml so that compile works with change detection. The following command will run compile when a file change is detected.
Terminal B
mvn fizzed-watcher:run
At this timing, try changing the Hello World character string of src / main / java / com / sightseekerstudio / MyResource.java
with an editor or the like.
Then, the compilation is executed in terminal B, and then the class of MyResource
that has been changed by compiling in terminal A is reloaded.
You can go to http: // localhost: 8080 again and see that the modified string is displayed.
Recommended Posts