2016 Utah State Park Attendance sample web application.
Companion application to the blog post at Volume Labs
Development of this application requires the following:
Developing the Application
Developing REST Services
The REST services are written in Java Utilizing Spring Boot & Spring MVC functionality. All of that code is located in
To develop the services code interactively just run
This will start up the embedded webserver (Tomcat by default) and serve your Services. As you write your code - the server should detect code changes and restart as necessary due the inclusion of Spring Boot DevTools.
gradlew bootRun -Dcors.origins=http://localhost:3000
This is because when developing the web application - it will be running on its own development server on port 3000 (see below) which will have a different host and we will need to configure CORS to allow the web application to consume the REST services.
All of the web application code is under
src/main/app. You will need to be in this directory to run the following commands.
The web application is packaged with webpack and utilizes webpack-dev-server to enable interactive development.
First you must download all of the necessary dependencies from npm.
npm run setup
Once that is complete you are ready to start the development server by simply running
npm start. However the application can be configured via an environment variable to connect to a REST server at any location.
This way you can work on the web application and connect to any instance of your API (dev/test environments). If you would like to connect to your local instance of the REST services that are running using the instructions above - you will just need to set the
REST_URL environment variable to
http://localhost:8080/api. The easiest way to do that is to just prepend the variable declaration to the start command like this:
REST_URL=http://localhost:8080/api npm start
The application is transpiled, packaged and available at http://localhost:3000.
This is why the CORS property must be configured properly above.
The development server communicates with your browser via web sockets - so any changes that are made to your code are
immediately re-packaged and available to your browser without needing to refresh. Like Magic!
Building the application
To compile and package the application just run this:
./gradlew bootRepackage on OSX/Linux
gradlew.bat bootRepackage on Windows.
This will download all dependencies, compile, then package the application in a runnable jar file located in build/libs/packaged-webapp-1.0-SNAPSHOT.jar. After it is packaged running the application is simple:
java -jar build/libs/packaged-webapp-1.0-SNAPSHOT.jar
This will start an embedded webserver (Tomcat) which you can access at http://localhost:8080. You can change the port if necessary by adding the
java -jar build/libs/packaged-webapp-1.0-SNAPSHOT.jar --server.port=8989