realistically this means refactoring some code not just removing the dependency. I'm working on a command line app that loads configs (that aren't related to the spring configs). I was having a problem with one of my DTO's so I went to write a @JsonTest (foolish name like Jackson prefixing everything with json, even though it might not be). Lo and behold, I found out this requires spring-web, even though I have no other use for it, I certainly wouldn't want it in my cli app, so for now I'm not using spring-boot-starter-json. I think it would be a good idea to use spring-web if it was on the classpath, but starter-json shouldn't bring it in and @JsonTest shouldn't require it.

Comment From: wilkinsona

Thanks for the suggestion but we can't remove the spring-web dependency. Spring Boot's opinion is that Jackson should be used for json serialisation and deserialisation. Our auto-configuration of Jackson uses Spring Framework's Jackson2ObjectMapperBuilder and it's part of the spring-web module. If we removed spring-web from spring-boot-starter-json you'd lose all beans related to Jackson-based json serialization and deserialisation.

You shouldn't need to have spring-web on the classpath to use @JsonTest. To use Jackson you'd have to define the ObjectMapper build yourself as the auto-configuration won't work for the reasons explained above. It should also be possible to use it without Jackson if you prefer Gson or the like instead. If that's not the case in your experience then please provide a minimal sample that fails when spring-web is excluded and we can fix it.

Comment From: xenoterracide

I did that (didn't have it on the classpath) and got a runtime error about Jackson2ObjectMapperBuilder (IIRC). I'm already defining ObjectMapper as I'm deserializing yaml.

Comment From: wilkinsona

I can't reproduce the behaviour I'm afraid. I can use @JsonTest and JacksonTester without spring-web on the classpath as long as I also define an ObjectMapper bean. Without the ObjectMapper, autowiring of JacksonTester fields fails.

If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: xenoterracide

sorry, I went to work on the minimal example after posting that, I should have mentioned. Turns out my memory is bad. It was jayway being missing that was causing the problem. My bad.

P.S. my project should actually help with the minimal example issue, since it's a scaffolding system. Though I could probably use spring initializer for spring problems.