Spring Fu is an incubator for new Spring features about Kotlin and functional bean registration.

Spring Fu

Spring Fu is an incubator for new Spring features about Kotlin and functional bean registration. It introduces Kofu and Jafu configuration for configuring Spring Boot in a functional way, Coroutines support, GraalVM native images support and various other features.

Spring Fu is an incubator for new Spring features about Kotlin and functional bean registration. Its main feature is an alternative way of configuring Spring Boot applications with Kotlin DSL and lambdas instead of annotations: Kofu (for Kotlin and functional) configuration. Other features like Coroutines or GraalVM support are also included.

A Java variant called Jafu (for Java and functional) is also available (just a POC for now).

It is not intended to be used in production, but rather to incubate and get feedback and contributions from the community in order to reach a point where its features can be integrated as part of existing Spring projects like Framework, Boot and Data. The table bellow summarize the status of current features.

Getting started

https://spring.io/blog/2018/10/02/the-evolution-of-spring-fu

Via start.spring.io

  • Create a Spring 2.1.x.RELEASE project on start.spring.io,
  • Add the org.springframework.fu:spring-fu-kofu:0.0.3.BUILD-SNAPSHOT dependency
  • Use Kotlin 1.3.0
  • Modify the generated *Application.kt file as following:
package com.example

import org.springframework.fu.kofu.application

val app = application {
    // ...
}

fun main() = app.run()



// 例如:
val app = application {
  import(beans)
  listener<ApplicationReadyEvent> {
    ref<UserRepository>().init()
  }
  properties<SampleProperties>("sample")
  server {
    port = if (profiles.contains("test")) 8181 else 8080
    mustache()
    codecs {
      string()
      jackson {
        indentOutput = true
      }
    }
    import(::routes)
  }
  mongodb {
    embedded()
  }
}

val beans = beans {
  bean<UserRepository>()
  bean<UserHandler>()
}

fun routes(userHandler: UserHandler) = router {
  GET("/", userHandler::listView)
  GET("/api/user", userHandler::listApi)
  GET("/conf", userHandler::conf)
}

fun main() = app.run()

Samples

You can also have a look to the sample applications.

Credits

In addition to the whole Spring and Reactor teams, special credits to:

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏一个会写诗的程序员的博客

NoClassDefFoundError: ch/qos/logback/classic/spi/ThrowableProxy

This warning, i.e. not an error, message is reported when no SLF4J providers cou...

3951
来自专栏Hongten

Hibernate4Maven

How to create a Maven project with Hibernate libs?

1583
来自专栏运维

CentOS 7.5安装部署Jewel版本Ceph集群

1、修改cpeh.conf文件 注意mon为奇数,如果为偶数,有一个不会安装,另外设置好public_network,并稍微增大mon之间时差允许范围(默认为0...

1043
来自专栏曾大稳的博客

OpenCv as配置

copy到opencv的javalib里面当so运行就可,调用initDebug初始化即可

1721
来自专栏算法修养

HDU 4238 You Are the One

You Are the One Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32...

3306
来自专栏一个会写诗的程序员的博客

Kotlin Compiler Plugins : All-open , Kotlin-spring,No-arg,Kotlin-jpaCompiler Plugins

Kotlin has classes and their members final by default, which makes it inconvenie...

1922
来自专栏一个会写诗的程序员的博客

LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Either remove Logba...

LoggerFactory is not a Logback LoggerContext but Logback is on the classpath. Ei...

3165
来自专栏大数据学习笔记

Flume1.8安装配置与入门实例

1、下载 http://flume.apache.org/download.html ? http://mirrors.tuna.tsinghua.edu.cn...

2656
来自专栏Netkiller

Spring Cloud Netflix

本文节选自《Netkiller Java 手札》 http://www.netkiller.cn 12.2. Spring Cloud Netflix 12....

2987
来自专栏Netkiller

Phalcon VS Spring 用法对照手册

Phalcon VS Spring 摘要 Phalcon VS Spring 用法对照表 ---- 目录 1. Install 1.1. Phalcon 1.2...

4106

扫码关注云+社区

领取腾讯云代金券