title: Variable 'interface' might not have been initialized
body: <p>I am trying to build a <code>Morphia</code> and <code>Spring</code> application using a template from another project and I am getting the following error</p>
  
  <pre><code>Variable 'assetRepository' might not have been initialized
  </code></pre>
  
  <p>The <code>AssetRepository</code> is an interface</p>
  
  <pre><code>package code.nithin.repository;
  
  import code.nithin.entity.Asset;
  import org.mongodb.morphia.Key;
  
  public interface AssetRepository {
      public Key&lt;Asset&gt; save(Asset asset);
  }
  </code></pre>
  
  <p>and the <code>AssetController</code> is</p>
  
  <pre><code>package code.nithin.controllers;
  
  import code.nithin.entity.Asset;
  import code.nithin.repository.AssetRepository;
  import org.mongodb.morphia.Key;
  
  public class AssetController{
  
      public String saveAsset(String URL){
          AssetRepository assetRepository;
          Asset test = new Asset(1, System.currentTimeMillis(),"https://example.com");
  
          String returnString = assetRepository.save(test).getId();
  
      }
  }
  </code></pre>
  
  <p>The entity is</p>
  
  <pre><code>package code.nithin.entity;
  
  import org.bson.types.ObjectId;
  import org.mongodb.morphia.annotations.Entity;
  import org.mongodb.morphia.annotations.Id;
  
  import lombok.Data;
  import lombok.NoArgsConstructor;
  
  @Data
  @Entity("asset")
  @NoArgsConstructor
  public class Asset {
  
      @Id
      public ObjectId _id;
  
      public int version;
      public long timestamp;
      public String URL;
  
      public Asset(){}
  
      public Asset(int version, long timestamp, String URL) {
          this.version = version;
          this.timestamp = timestamp;
          this.URL = URL;
      }
  
      public ObjectId get_id() {
          return _id;
      }
  
      public void set_id(ObjectId _id) {
          this._id = _id;
      }
  
      public int getVersion() {
          return version;
      }
  
      public void setVersion(int version) {
          this.version = version;
      }
  
      public long getTimestamp() {
          return timestamp;
      }
  
      public void setTimestamp(long timestamp) {
          this.timestamp = timestamp;
      }
  
      public String getURL() {
          return URL;
      }
  
      public void setURL(String URL) {
          this.URL = URL;
      }
  }
  </code></pre>
  
  <p>The project I am referring to implements the same as</p>
  
  <pre><code>@Bean
  public CommandLineRunner init(AssetRepository assetRepository){
      return (args) -&gt; {
          Asset test = new Asset(1, 123456789632541 ,"https://example.com");
          System.out.println(assetRepository.save(test).getId());
      };
  }
  </code></pre>
  
  <p>The project I am referring to throws no error.</p>
  
  <p>Stack trace</p>
  
  <pre><code>Error:(19, 28) java: variable assetRepository might not have been initialized
      Error:(21, 5) java: missing return statement
      /home/signzy/code/java/cubereum/boilerplate/src/main/java/code/cubereum/controllers/AssetController.java
      Information:javac 1.8.0_181 was used to compile java sources
      Information:1/9/18 2:58 PM - Compilation completed with 2 errors and 0 warnings in 1 s 730 ms
      Information:java: Errors occurred while compiling module 'boilerplate_main'
  </code></pre>