tgirard12 / spring-webflux-kotlin-dsl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Kotlin dsl to start standalone Spring WebFlux Application

This project is based on https://github.com/sdeleuze/spring-kotlin-functional

The Main idea of this project is to provide a beautiful DSL to start a Spring Application on netty :

  • Simple DSL
  • No Annotation
  • No JavaConfig
  • No Classpath Scanning

Application dsl sample :

fun main(args: Array<String>) {
    webfluxApplication(Server.NETTY) { // or TOMCAT
    
        // group routers
        routes {
            router { routerApi(ref()) }
            router(routerStatic())
        }
        router { routerHtml(ref(), ref()) }
    
        // group beans
        beans {
            bean<UserHandler>()
            bean<Baz>()  // Primary constructor injection
        }
        bean<Bar>()
    
        mustacheTemplate()
    
        profile("foo") {
            bean<Foo>()
        }
    }.run()
}

This project use :

Current master branch is based on standalone WebFlux runtime. Spring Boot is based on JavaConfig and does not provide specific support functional bean definition yet (see this issue where this is discussed). That said, it is possible to use experimentally Spring Boot + functional bean definition together via ApplicationContextInitializer, see this Spring Boot branch for a concrete example.

Build the project and run tests with ./gradlew build, create the executable JAR via ./gradlew shadowJar, and run it via java -jar build/libs/spring-kotlin-functional-1.0.0-SNAPSHOT-all.jar.

About


Languages

Language:Kotlin 94.0%Language:HTML 4.8%Language:JavaScript 1.2%