There is no such thing as perfect programming, but we shouldn’t be discouraged because programming is a constant pursuit of perfection.
Since the interface in the Service layer is used in multiple places during development, the implementation class to be used needs to be specified otherwise the injection will fail. This is what @primary does:
@Service
@Primary
public class TranServiceImpl implements TranService {
}
Copy the code
Because used in the development, and feel very useful, so write out, hope to help home.