Skip to content

Latest commit

 

History

History

sample-app-spring-boot

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Kontent.ai Sample Spring Boot App

Showcase of the Spring boot application displaying data from Kontent.ai.

Get starred

First build the whole monorepo and then run in the root of this repository:

./gradlew :sample-app-spring-boot:bootRun

Now visit http://localhost:8080 and see a little subset of Dancing Goat!

Application screenshot

Features

Generated strongly-typed models with view models transformation using Thymeleaf template engine

This showcase is using model generator for generating models. The models are generated in the /src/main/java/kontent/ai/delivery/sample/dancinggoat/models - this generation is configured to be run as a gradle task called generateModels as described in model generators README.

These models are then configured to be found in Kontent.aiConfiguration.java by using scanClasspathForMappings method.

You could then use DeliveryClient to get strongly typed model as showcased in i.e. AboutUs model in AboutUsController.java.

Automatic rich text component resolution

SDK provides automatic resolution of the linked components and inline linked items in rich text. This could be showcased on http://localhost:8080/articles/coffee-beverages-explained.

Automatic video component resolution

The only thing to do it to create a display template named by the codename of the content type - hosted_video.html in this case - and then just load strongly typed model in the controller (ArticleController.java) and that's it.

Custom rich text component

If you wish to resolve the components/inline linked items in rich text.You could use registerInlineContentItemsResolver method as showcased in KontentConfiguration.java.

AUtomatic video component resolution

How to connect to your own project

You could generate your own Sample project by using Sample site configuration page using "Create a new Sample Project" button.

Then use this project in the app:

  1. In Kontent.ai, choose Project settings from the app menu.
  2. Under Development, choose API keys.
  3. Copy your Project ID.
  4. And then set the project ID to Kontent.aiConfiguration.java. 1.Then re-run the ./gradlew :sample-app-spring-boot:bootRun

Further SpringBoot Resources

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely: