spring-kotlin-functional | Spring Framework Kotlin APIs, the functional way | Application Framework library
kandi X-RAY | spring-kotlin-functional Summary
kandi X-RAY | spring-kotlin-functional Summary
This project is designed to demonstrate Spring Framework 5 Kotlin support and Functional web and bean APIs used together:. 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.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of spring-kotlin-functional
spring-kotlin-functional Key Features
spring-kotlin-functional Examples and Code Snippets
Community Discussions
Trending Discussions on spring-kotlin-functional
QUESTION
At https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt the comment shows how to define Spring Beans via the new "Functional bean definition Kotlin DSL". I also found https://github.com/sdeleuze/spring-kotlin-functional. However, this example uses just plain Spring and not Spring Boot. Any hint how to use the DSL together with Spring Boot is appreciated.
...ANSWER
Answered 2017-Sep-07 at 15:01Spring Boot is based on Java Config, but should allow experimental support of user-defined functional bean declaration DSL via ApplicationContextInitializer
support as described here.
In practice, you should be able to declare your beans for example in a Beans.kt
file containing a beans()
function.
QUESTION
I'm trying to follow the demo https://github.com/sdeleuze/spring-kotlin-functional to create a new Spring Boot application using the annotation-free new approach, released in Spring Boot 2. My problem is how to continue to use Yaml files to configure my application, without using annotations? I would guess it would be something inside the Beans configuration but I dont find any documentation on that subject. Thanx
...ANSWER
Answered 2018-Apr-03 at 13:05The beans
dsl has an env
property that you can use to retrieve any environment
property defined in yaml, properties files or command line parameters:
QUESTION
I just take some experiments with spring webflux 5.0.0 and Kotlin, and I have problem with loading configuration from application.yml
For base project I start with this example spring-kotlin-functional
But there are only manual loading beans and routing without any loading from configuration files or example how to implement analog of @ConfigurationProperties class in such way.
I have try to take environment in beans section:
...ANSWER
Answered 2017-Oct-19 at 17:06Spring boot is just a dependency management that build auto-configuration that you can override. All the feature are inherited from Spring framework and modules. So basically you could do the same with or without boot.
I'm not on webflux yet. But as you reference your other beans, you mat need to declare a configuration bean elsewhere.
I'm sure I'll help you with that...
QUESTION
It seems that the @PostConstruct method is not called when a bean is added to the context using a Kotlin BeanDefinitionDsl.
This happened to me in my own project but to create a simple way to reproduce it, here's what I did.
- I forked the Spring example of using the Kotlin DSL https://github.com/sdeleuze/spring-kotlin-functional
- I added a @PostConstruct to the UserHandler class. (More details below.)
- I pushed the result here: https://github.com/benjishults/spring-kotlin-functional
So all you need to do is fork my repo and do a gradle run.
My questions are:
- Shouldn't I expect that @PostConstruct to be called since I'm bringing the class in as a bean?
- Am I missing a step?
- Is this a Spring bug?
If you don't want to pull my repo, here are more details about what I did. I added this to the UserHandler class:
...ANSWER
Answered 2017-Oct-18 at 06:55GenericApplicationContext
instantiated in the Application
class does not support out of the box @PostContruct
. To make it works, you should use AnnotationConfigApplicationContext
instead and remove the exclude for spring-aop
in the Gradle build.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install spring-kotlin-functional
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page