title: Deserializing Scala list with Jackson
body: <p>I have a case class that returns looks something like this</p>
  <pre><code>case class Response(
    @JsonDeserialize(contentAs = classOf[java.lang.Long])
    longList: List[Long] = null)
  </code></pre>
  <p>I have a customer ObjectMapper, that among other things registers DefaultScalaModule. According to <a href="https://github.com/FasterXML/jackson-module-scala/wiki/FAQ" rel="nofollow noreferrer">https://github.com/FasterXML/jackson-module-scala/wiki/FAQ</a>, adding @JsonDeserialize should solve the issue, but it doesn't</p>
  <p>The issue is in my tests, and I get the following error message</p>
  <blockquote>
  <p>java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long</p>
  <p>at scala.runtime.BoxesRunTime.unboxToLong(BoxesRunTime.java:105)</p>
  </blockquote>
  <p>Test class, list.head is what triggers the error</p>
  <pre><code>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
  class ControllerTest {
    @Autowired
    var testRestTemplate: TestRestTemplate = _
    @Autowired
    var objectMapper: ObjectMapper = _
  
    @Test 
    def test() : Unit = {
      val response = testRestTemplate.exchange(&quot;url&quot;, HttpMethod.GET, classOf[Response])
      val list = response.getBody.longList
      val a = list.head
    }
  }
  </code></pre>
  <p>Debugging tells me that my list is actually of type $colon$colon containing Integers</p>