Spring
Introduction
The Spring Framework provides first-class support for Kotlin and lets developers write Kotlin applications almost as if the Spring Framework was a native Kotlin framework. Most of the code samples of the reference documentation are provided in Kotlin in addition to Java.
Spring Boot
Spring Boot is a framework that simplifies the creation of stand-alone, Spring based applications.
Create a new “JVM Application” with Amper
To enable Spring Boot support, add the following to the module.yaml file:
settings:
springBoot: enabledMixed projects (containing Java and Kotlin sources simultaneously) are supported.
Examples of Spring Boot projects:
RESTful Web Service
You will build a service that will accept HTTP GET requests at http://localhost:8080/greeting.
It will respond with a JSON representation of a greeting, as the following listing shows:
You can customize the greeting with an optional name parameter in the query string, as the following listing shows:
http://localhost:8080/greeting?name=UserThe name parameter value overrides the default value of World and is reflected in the response, as the following listing shows:
Estàs llegint una vista prèvia.
Inicia sessió per llegir l'article complet. Qualsevol compte obre 4 articles gratuïts al mes; l'alumnat i el professorat llegeixen les pàgines del seu curs sense límit.
Inicia sessió