question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add jackson-kotlin-module in a Kotlin-based project when Jackson is present

See original GitHub issue

As asked on #152 and as a follow-up of #400, I create a dedicated issue for discussing a way to add jackson-kotlin-module for Spring Boot + Kotlin + Jackson projects (mostly Web and Reactive Web projects) with a copy & paste of my #152 last comment.

I truly understand this is not an easy one, but even with documentation, projects using Boot + Kotlin + Jackson (vast majority of Kotlin projects) are broken out of the box for use cases as simple as writing a REST webservice. IMO even experienced developers will forget to add it 50% of the time because with start.spring.io, we have the habits of just generating a project, write classes, run and it works. So when I saw this issue I thought it would be interesting to discuss if it could be use to help for such use case (even if maybe it is not).

Having the capability to add a post-processor able to inspect transitive dependencies and add jackson-kotlin-module dependency when jackson-databind is found in transitive dependencies and when "language == 'kotlin'" would be awesome, but as you said that’s not possible easily currently and that’s not what I had in mind.

My proposal is a more basic approach where we leverage the new feature discussed here to add for dependencies like “Web” and “Reactive Web” (maybe a few others like “Ratpack” or “Vaadin” if that makes sense) an additional jackson-kotlin-module dependency if a condition like "language == 'kotlin'" is fulfilled. This is not a perfect solution (duplication in the meta-data, will not cover all use cases if we focused on the most common dependencies requiring Jackson) but given the current set of constraints, I thought it could be a possible one.

Any thoughts?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
snicollcommented, Jul 26, 2017

We’ve decided to add the dependency in Spring Boot’s json starter.

0reactions
sdeleuzecommented, Jul 24, 2017

@bclozel Good point, adding jackson-module-kotlin (with exclusion of koltin-reflect dependency) to spring-boot-starter-json as described in https://github.com/spring-projects/spring-boot/issues/9803 would solve this issue on Springn Boot side, so that would be even better.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jackson Support for Kotlin - Baeldung
In this tutorial, we'll discuss the Jackson support for Kotlin. We'll explore how to serialize and deserialize both Objects and Collections. We' ...
Read more >
Parsing data with Jackson using kotlin | ProAndroidDev
An introduction to Jackson Kotlin module and Kotlin nullable type for missing values in data. Jackson is one of the famous library to...
Read more >
SpringBoot 2.5.0 For Jackson Kotlin classes support please ...
Edit: Just upgrade to Spring Boot 2.5.1 where this is resolved. Old answer below: I managed to fix this for now by adding...
Read more >
jackson-module-kotlin : 2.11.2 - Maven Central
jackson -module-kotlin - Add-on module for Jackson (https://github.com/FasterXML/jackson/) to support Kotlin language, specifically introspection of ...
Read more >
Kotlin: create REST services using Jersey and Jackson
This is done by adding a question mark to the type, for example String versus String?. The biggest difference, however, in comparison to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found