0 likes | 9 Views
Kotlin has emerged as a big player among modern technology. With Google providing first hand support and announcing it as the official language for Android Development it is clear that Kotlin is here to stay.<br><br>Kotlin has emerged as a big player among modern technology. With Google providing first hand support and announcing it as the official language for Android Development it is clear that Kotlin is here to stay.
E N D
Byteridge Creating a RESTful Web Service using Kotlin and Spring Boot
Byteridge Introduction • Kotlin has emerged as a big player among modern technology. With Google providing first hand support and announcing it as the official language for Android Development it is clear that Kotlin is here to stay. • Kotlin has emerged as a big player among modern technology. With Google providing first hand support and announcing it as the official language for Android Development it is clear that Kotlin is here to stay. • Spring Boot is one of the more popular frameworks for creating web services. Spring Framework 5 comes with Kotlin support. This means that Spring Boot 2.x will have first class support for Kotlin.
Byteridge Creating a simple REST controller with Spring Boot • Create a new project using the + New Project button and select ‘Spring Initializer’ and click next. • Give a name to your group and artifact. Select Type as Gradle and language as Kotlin and we will be using JAR packaging for our project and click next. • We will be using the latest stable version of Spring so select that from the options available.
Byteridge Creating a simple REST controller with Spring Boot • We can also search for and select which spring boot starters we want to use. Since this will be a react REST service we want reactive web. Select and click Next. • Give your project a name and click Finish. • After the project builds we can see a Kotlin directory has been created along with a standard default Spring boot application class.
Byteridge Creating a simple REST controller with Spring Boot • We will not create a RestController class. To keep things simple we will put it in the same Kotlin file. We will use the @RestController annotation and create a simple method which will return Flux, a constant stream of data.(This is where the reactive part comes in). • As a modal we will create a Kotlin data class which will accept 3 parameters in its constructor. (These will be returned in the Api response.) • Now, We will return Flux from our prices method. We will be using the interval method for returning the prices at 1 second interval. Prices will be generated randomly between 0 to 100.
Byteridge CONTACT US Contact:+91 40491 74522 Mail : info@byteridge.com Address: WeWork Rajapushpa Summit, Financial District, Hyderabad, Telangana Visit here for more : https://www.byteridge.com/technology-trends/creating-a-restful-web-service-using-kotlin-and-spring-boot/