-
Notifications
You must be signed in to change notification settings - Fork 45
devon4j deployment
As we already mentioned when introducing the devon4j projects, the apps created with the devon4j archetype are going to provide, apart from the core project and api project, a server project that will configure the packaging of the app.
In our Jump the Queue app we can verify that we have this server project available
So, using Maven, we are going to be able to easily package our app in a .war file to be deployed in an application server like Tomcat (the default server provided in devonfw).
The server project provided in devon4j applications is an almost empty Maven project. It only has a pom.xml file that is used to configure the packaging of the core project. Taking a closer look to this pom.xml file we can realize that it only presents a single dependency to the core project.
...
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jumpthequeue-core</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
...
And then it includes the spring-boot-maven-plugin that allows us to package the project in a jar or war archives and run the application "in-place".
...
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
...
So thanks to Spring Boot and the spring-boot-maven-plugin
we can run our app using Maven. To do so just open a command line with access to Maven (in Devonfw we can do it using the console.bat). And:
1.- As is explained in devonfw documentation the application.properties
used for packaging is /src/main/resources/application.properties
. So we need to edit the app properties to access to the app. In /jtqj-core/src/main/resources/application.properties
configure the properties:
server.port=8081 server.servlet.context-path=/jumpthequeue
2.- install the jtqj/core
project in our local Maven repository
D:\Devon-dist\...\jump-the-queue\java\jtqj\core>mvn install
3.- Go to the jtqj/server
project and execute the command mvn spring-boot:run
D:\Devon-dist\...\jump-the-queue\java\jtqj\server>mvn spring-boot:run
The app should be launched in the Spring Boot embedded Tomcat server. Wait a few seconds until you see a console message like
[L: org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainer] - [M: Tomcat started on port(s): 8081 (http)] [L: com.cap.jumpthequeue.SpringBootApp] - [M: Started SpringBootApp in 17.908 seconds (JVM running for 19.148)]
Now we can try to access to the app resource (GET)http://localhost:8081/jumpthequeue/services/rest/visitormanagement/v1/visitor/1
we can verify that the app is running fine
In the same way, using Maven we can package our project in a .war file. As in the previous section, open a command line with access to Maven (in devonfw console.bat script) and execute the command mvn clean package
in the project root directory
D:\Devon-dist\...\jumpthequeue>mvn clean package
The packaging process (compilation, tests and .war file generation) should be launched. Once the process is finished you should see a result like
[INFO] Building war: D:\Devon-dist\workspaces\jumpthequeue\server\target\jumpthe queue-server-0.0.1-SNAPSHOT.war [INFO] WEB-INF\web.xml already added, skipping [INFO] [INFO] --- spring-boot-maven-plugin:1.5.4.RELEASE:repackage (default) @ jumptheq ueue-server --- [INFO] Attaching archive: D:\Devon-dist\workspaces\jumpthequeue\server\target\ jumpthequeue-server-bootified.war, with classifier: bootified [INFO] ------------------------------------------------------------------------ [INFO] Reactor Summary: [INFO] [INFO] jumpthequeue ....................................... SUCCESS [ 0.306 s] [INFO] jumpthequeue-core .................................. SUCCESS [ 27.723 s] [INFO] jumpthequeue-server ................................ SUCCESS [ 6.628 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 35.091 s [INFO] Finished at: 20XX-06-28T10:11:37+02:00 [INFO] Final Memory: 48M/216M [INFO] ------------------------------------------------------------------------
The packaging process has created a .war file that has been stored in the \java\jtqj\server\target
directory.
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).