Spring Boot + Kotlin + AngularJS + WebJar CRUD Example Part 2

Spring Boot + Kotlin + AngularJS + WebJar CRUD Example
Spring Boot + Kotlin + AngularJS + WebJar CRUD Example

In previous part of Spring Boot + Kotlin + AngularJS + WebJar CRUD Example we see the basic tutorial in which create Spring Boot application and in this part we’ll add Kotlin dependency in Spring Boot application.

What is and Why Kotlin?

Kotlin is a general purpose, statically type and open-source programming language. Kotlin targets Java, Android, JavaScript, etc. It is run on JVM. It can be used where Java is used today, such as Android apps development, server side development and much more.

See this : Kotlin Problems and How to avoid them?

Features of Kotlin

  • Concise: Kotlin reduces writing the extra codes. This make Kotlin more concise.
  • Null safety: Kotlin is null safety language. Kotlin aimed to eliminate the NullPointerException (null reference) from the code.Interoperable:
  • Interoperable: Kotlin easily call the Java code in a natural way as well as Kotlin code can be used by Java.
  • Smart cast: It explicitly typecast the immutable values and inserts the value in its safe cast automatically.
  • Compilation Time: It has better performance and fast compilation time.
  • Tool-friendly: Kotlin program are build using command line as well as any of Java IDE.
  • Extension function: Kotlin supports extension functions and extension properties. Which means it helps to extend the functionality of classes without touching their code.

File Structure

You’ll have to delete SpringBootCrudApplication.java from co.tellmehow.kotlin package and add Kotlin class(SpringBootCrudApplication.kt) instead of it. And now file structure would be:


import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.EnableAutoConfiguration
import org.springframework.context.annotation.ComponentScan

class SpringBootCrudApplication

fun main(args: Array<String>)
  SpringApplication.run(SpringBootCrudApplication::class.java, *args)
  println(" **** Spring Boot + Kotlin + AngularJS CRUD Example!!! *****")

Kotlin dependency in pom.xml

Add Kotlin version inside properties tag(<properties>)


Add Kotlin dependencies

<!-- Kotlin -->

Now add Kotlin plugins inside plugin tag(<plugins>)

<!-- Kotlin plugins -->

Note: Don’t worry about pom.xml. I’ll give you full pom.xml code in last part.

Run your SpringBootKotlinApplication.kt and your SpringBoot application is now connect with Kotlin.

In next part we’ll create REST service using Spring Boot with Kotlin which will use as backend of our CRUD application. So stay with us.

Share your thoughts

Loading Facebook Comments ...
Loading Disqus Comments ...