-
Notifications
You must be signed in to change notification settings - Fork 45
build devon4j application
In this chapter we are going to show how to create a new devon4j application from scratch. The app that we are going to create is Jump the Queue, a simple app to avoid the queue in an event registering a visitor and obtaining an access code. You can read all the details of the app in the Jump the Queue Design page.
The recommended way to start developing devon4j applications is to get the last devonfw distribution to have a ready-to-start development environment.
You can download devonfw distributions from here.
To see what is included in a devonfw please visit the devonfw intro section.
Once the download is done extract the zip file and you will get the distribution’s content.
Before creating our first project you must initialize the distribution. To do so execute the script
update-all-workspaces.bat
Now you should see the conf directory and the Eclipse launchers.
Note
|
Learn more about devonfw initialization here |
First, in the workspaces directory of the distribution create a new folder jumpthequeue and go into it.
Execute console.bat to get a console initialized with the provided software served in the software
folder.
Note
|
Even though this tutorial is following an structure similar to MyThaiStar. If you are using the devonfw distribution, we recommend the use of the workspaces as a folder to create the project. We recomend to adapt the parameters appropriately. Once you finished generating the project, execute the script |
D:\Devon\workspaces>mkdir jumpthequeue
D:\Devon\workspaces>cd jumpthequeue
D:\Devon\workspaces>mkdir java
D:\Devon\workspaces>cd java
We are going to generate the new devon4j project using Devcon. To launch the tool run the 'console.bat' script, in the new opened command line window execute the command
devcon -g
You should see the Devcon's graphic interface. Select devon4j
and create
Then we only need to define our server app serverpath (for the location of the app select our just created jumpthequeue/java directory), servername, packagename, groupid, version and dbtype. Finally click on Start button.
Once you see the BUILD SUCCESS
info message your new app is ready.
As last step we can import the project we just created into the Eclipse IDE provided with devonfw. Although our new devon4j based app is still empty we are going to show how to run it with Spring Boot simply to check that everything is ok.
We could use the eclipse-main.bat or the eclipse-examples.bat launchers (that you should see on your distribution’s root directory) but we are going to create a new Eclipse launcher related to our new project.
To do it launch again the script
update-all-workspaces.bat
After the process is done you should see a new eclipse-jumpthequeue.bat launcher. Execute it and a new Eclipse instance should be opened.
Now import our new project with File > Import
.
Select Maven/Existing Maven Projects
Browse for the jumpthequeue project
Click Finish
and wait while the dependencies of the project are resolved to complete the import process.
Now let’s change the server context path of our application. Open /jtqj-core/src/main/resources/config/application.properties
and set the server.context-path
property to /jumpthequeue
server.servlet.context-path=/jumpthequeue
Note
|
You can also change the port where the application will be available with the property |
Finally, using Spring Boot features (that provides us with an embedded Tomcat), we can run the app in an easy way. Look for the SpringBootApp.java
class and click right button and select Run As > Java Application
.
If everything is ok you will see a messages in the Console window like
INFO [main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8081 (http) INFO [main] com.cap.jumpthequeue.SpringBootApp : Started SpringBootApp in 16.978 seconds (JVM running for 17.895)
The app will be available at 'http://localhost:8081/jumpthequeue'
Note
|
You are redirected to the login screen because, by default, the new devon4j applications provide a basic security set up. |
Creating devon4j based apps we get the following main features out-of-the-box:
-
Maven project with api project, core project and server project:
-
api project for the common API
-
core project for the app implementation
-
server project ready to package the app for the deployment
-
-
Data base ready environment with an h2 instance
-
Data model schema
-
Mock data schema
-
Database version control with Flyway
-
Bean mapper ready
-
Basic security enabled (based on Spring Security)
-
Unit test support and model
Next chapter: Add a component to your app
This documentation is licensed under the Creative Commons License (Attribution-NoDerivatives 4.0 International).