Setting up
KVision supports three server-side frameworks - Ktor, Jooby and Spring Boot - so you have to choose one of them for your needs. It's worth to mention, that common and frontend targets of your application are exactly the same for all three servers, as well as the greater part of the actual service implementation in the backend target. The differences are tied to the actual framework build configuration and initialization code.
KVision full-stack applications utilize Kotlin multiplatform architecture (Kotlin 1.3 MPP). That's why you have to prepare the special Gradle configuration and the project layout. To start, it's best to just clone one of the template-fullstack projects from kvision-examples GitHub repository.
The application sources are split into three source sets - common
, frontend
and backend
, located in three directories: src/commonMain
src/frontendMain
and src/backendMain
. The requirements and dependencies for build process are the same as mentioned in Part 1 of this guide.
Development
During the development phase you compile and run frontend and backend targets separately.
Frontend
To run the frontend application with Gradle continuous build enter:
Backend
To run the backend application enter:
All three frameworks have auto-reload feature, but only Jooby is watching for changes directly in the source code. In case of Ktor and Spring Boot auto-reload is based on the classpath monitoring, so you have to run another Gradle process for continuous build:
After both parts of your application are running, you can open http://localhost:3000/ in your favorite browser. Changes made to your sources (in any source set) should be automatically applied to your running application.
Production
To build complete application optimized for production run:
The application jar will be saved in build/libs
directory (projectname-1.0.0-SNAPSHOT.jar
). You can run your application with thejava -jar
command.
Last updated