Creating a WildFly Swarm project

Let’s use WildFly Swarm Project Generator at http://wildfly-swarm.io/generator/ to select the specifications we want to include in our application and to create the starter project:

Figure 12.3: WildFly Swarm Project Generator

Enter Group ID and Artifact ID as shown in the previous screenshot. In the Dependencies textbox, start typing features such as JPA or JAX-RS and then select them from the auto-suggested options. Make sure JPA EclipseLink , JAX-RS, and CDI are selected as dependencies. If you want to see all available dependencies and select from that list, then click the View all available dependencies link.

Click the Generate Project button to create the project and download the ZIP file. This is a Maven project. Unzip the file in a folder and import the project as a Maven project in Eclipse (by selecting the menu option File | Import and then selecting Existing Maven Projects in the Maven category).

Right-click on the Eclipse Project Explorer and select Run As | Maven Build. In the configuration window, type wildfly-swarm:run in the Goals field:

Figure 12.4: Maven Build Configuration to create a WildFly Swarm application

Click Run. Maven will download and install the dependencies and then run the application (you will see a Wildfly Swarm is Ready message in the console when the application is ready). Open http://localhost:8080/hello to test the default endpoint created by the application generator. You should see the hello message.

If you look into the target folder of the project, you will see demo-swarm.jar and demo.war. When we executed the wildfly-swarm:run goal, Maven starts a JBoss container and deploys the WAR file. The microservice can also be run by executing the single JAR file, demo-swarm.jar. This JAR contains all the packages, including the application server to run the microservice. Simply run this from the command line:

java –jar demo-swarm.jar

To change the name of the output file from demo to, say, coursemanagement, change the name in pom.xml in <filename> under the <build> tag.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.22.77.63