title: How to convert this Java code to Kotlin Code?
body: <p>I'm learning spring boot and new to kotlin.
  A error will be reported when this Java function convert to kotlin code.
  How to rewrite this kotlin function?</p>
  
  <p><a href="https://spring.io/guides/gs/consuming-rest/" rel="nofollow noreferrer">https://spring.io/guides/gs/consuming-rest/</a></p>
  
  <pre><code>@Bean
  public CommandLineRunner run(RestTemplate restTemplate) throws Exception {
      return args -&gt; {
          Quote quote = restTemplate.getForObject(
                  "http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
          log.info(quote.toString());
      };
  }
  </code></pre>
  
  <p>After convert these code to kotlin by idea:</p>
  
  <pre><code> @Bean
  @Throws(Exception::class)
  fun run(restTemplate: RestTemplate): CommandLineRunner {
      return { args -&gt;
          val quote = restTemplate.getForObject(
                  "http://gturnquist-quoters.cfapps.io/api/random", Quote::class.java)
          log.info(quote.toString())
      }
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/ganID.png" alt="Type mismatch"></p>
  
  <p>Please tell me how to correct this code.</p>