Weather spring mvc or not, you always need to code the interface. The interface gives me better readability when I just want to see what the class does and not worry about how it does it, like an API that is open to the outside world.
Another advantage can be multiple "how to do" implementations, and spring helps you easily switch between multiple implementations. E.g. you may have another implementation of EmployeeService, e.g. FullTimeEmployeeServiceImpl, RemoteEmployeeServiceImpl.
Now, if you have a client class that uses EmployeeService:
class EmployeeManager{ private EmployeeService service; }
you can enter any of the bean here
<bean id="employeeManager" class="com.abc.EmployeeManager"> <property name="service" ref="fullTimeEmployee | remoteEmployee" > </bean> <bean id="fullTimeEmployee" class="com.abc.FullTimeEmployeeServiceImpl" /> <bean id="remoteEmployee" class="com.abc.RemoteEmployeeServiceImpl" />
source share