Hands-On Cloud Development with WildFly
上QQ阅读APP看书,第一时间看更新

Adapting to WildFly Swarm

Now we all know how to create Java EE applications, described previously, but we are here to learn how to use WildFly Swarm, so let's adopt the preceding application for it. Let's roll up our sleeves as we have some hard work to do now.

We have to modify pom.xml:

(...)

<dependencies>
<!-- 1 -->
<dependency>
<groupId>org.wildfly.swarm</groupId>
<artifactId>jaxrs</artifactId>
<version>${version.wildfly.swarm}</version>
</dependency>
</dependencies>

<build>
<plugins>
(...)
<!-- 2 -->
<plugin>
<groupId>org.wildfly.swarm</groupId>
<artifactId>wildfly-swarm-plugin</artifactId>
<version>${version.wildfly.swarm}</version>
<executions>
<execution>
<goals>
<goal>package</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

</project>

We had to add dependencies to Swarm's JAX-RS module (1). Such modules are called fractions and you will learn more about them in the next chapter. Please note that we don't need to configure the JAX-RS API dependency directly as it will be provided as the JAX-RS fraction dependency.

Later, we had to configure WildFly Swarm's Maven plugin, which is responsible for building Swarm microservices (2). You will also learn more about it in the next chapter.

That's it. Congratulations! You have just created your first WildFly Swarm application.

Examples reference: chapter2/swarm-hello-world (the whole example is available in the attached code, in the directory: chapter2/swarm-hello-world directory.)