title: Is it right to use spring DI without interface
body: <p>I am using spring dependency injection,where i can inject object dependency through some external xml file.</p>
  
  <p>My question is : </p>
  
  <p><strong>Is it fine to use spring DI without using interfaces?</strong></p>
  
  <p>Because with DI,we want to achieve one thing :</p>
  
  <p>If a class is being replaced by some other class having same methods but different definitions,then we don't need to make any change in code where this class is being referenced.</p>
  
  <p>This is fine if i am using interface as interface can point any class which is implementing this interface but if i am directly injecting class object through DI then there is no meaning of DI because in this case if class get replaced,i have to change my code also where it is being referenced.</p>
  
  <p>Please let me correct if something is wrong.</p>
  
  <p>Let's say i have </p>
  
  <pre><code>Class Datasource{
  
      String url;
      String user;
      String database;
  
  }
  </code></pre>
  
  <p>Now i am using it without DI as</p>
  
  <pre><code>Class Abc{
  
       Datasource datasource = new Datasource();
  }
  </code></pre>
  
  <p>what's the problem in this and what are the benefits i can get if i use DI.</p>
  
  <p>Is getting singleton object only goal of DI?</p>