First there is no restriction in Spring about implementations, you are free to implement classes as much as you want.
The exmaple below may help you to understand multiple implementations, and how you can chose one at runtime:
Suppose you have 2 DAO classes one for Oracle, the seconde for MySQL, and both classes are implementing a DAO interface. You define an implementation as a bean in Spring configuration file. In the business class you have an attribut of type DAO, while in the spring configuration file you choose the real type wheather Oracle or MySQL to inject or using spring annotation @Autowired
.
This reduce coupling and it will be easy to move from Oracle to MySQL.
@Service
public class Business {
@Autowired
private Dao daoImpl;
//Business methods that invoks Dao methods
}
In the Spring configuration file (XML file) you use the following:
<bean id="daoImpl" class="app.com.MySQLDaoImpl OR app.com.OracleDaoImpl"/>
By just changing the class attribut of your bean you change the whole implementation, without any change in your business class
This is the original answer.