Escribe para buscar…

Spring

Esta página todavía no se ha traducido — se muestra en su idioma original:English

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 Framework - Kotlin

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:

yaml
settings:
    springBoot: enabled

Mixed projects (containing Java and Kotlin sources simultaneously) are supported.

Examples of Spring Boot projects:

Amper - Spring

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:

json
{"id":1,"content":"Hello, World!"}

You can customize the greeting with an optional name parameter in the query string, as the following listing shows:

http://localhost:8080/greeting?name=User

The name parameter value overrides the default value of World and is reflected in the response, as the following listing shows:

json
{"id":1,"content":"Hello, User!"}

Estás leyendo una vista previa.

Inicia sesión para leer el artículo completo. Cualquier cuenta abre 4 artículos gratuitos al mes; el alumnado y el profesorado leen las páginas de su curso sin límite.

Iniciar sesión