spring-boot-starter-json cannot be used standalone

Created on 17 Aug 2017  路  3Comments  路  Source: spring-projects/spring-boot

The current spring-boot-starter-json is a bit weird for two reasons:

  • It does not bring the base starter (spring-boot-starter) so if you only bring that, the app doesn't even compile. All others starters bring the base starter AFAIK
  • Nothing "json-specific" is auto-configured as Jackson2ObjectMapperBuilder is not present. We would need to add spring-web to make that happen

IMO, both should be added as otherwise this starter is more a collection of libs rather than something a user can add to an app to get some additional behaviour.

dependency-upgrade

Most helpful comment

Actually, I guess you could argue that JSON is mainly a web technology and the chances are if you're using JSON you're either sending or receiving it over HTTP. Unless @jhoeller has plans to relocate Jackson2ObjectMapperBuilder and friends to to org.springframework.core.json, we probably don't have any choice but to add the spring-web dependency.

Having Jackson without the Jackson2ObjectMapperBuilder is a bit pointless.

All 3 comments

Indeed, spring-boot-starter should be added here.
Technically, this can be seen as a "collections of libs shared by several starters"; so definitely not a good citizen amongst starters, but it is still quite useful.

Also, we've just talked how this could be used by others (like Jersey) - but I still feel that adding spring-web is the right move. In the end, we are trying to configure codecs/(de)serialization for web applications. Since Jackson also supports other formats (CBOR, CSV, etc), we should draw the line now and decide what's the scope of it.

+1 to adding spring-boot-starter but I'm not totally sold on spring-web. It's a shame that Jackson2ObjectMapperBuilder lives in that package because it's not really tied to web.

Actually, I guess you could argue that JSON is mainly a web technology and the chances are if you're using JSON you're either sending or receiving it over HTTP. Unless @jhoeller has plans to relocate Jackson2ObjectMapperBuilder and friends to to org.springframework.core.json, we probably don't have any choice but to add the spring-web dependency.

Having Jackson without the Jackson2ObjectMapperBuilder is a bit pointless.

Was this page helpful?
0 / 5 - 0 ratings