You need to have a strong mind and the will power to be able to get through with all the failures you encounter. Accept that life wouldn't always go our way no matter how careful we planned it to be. Realizing that failures do not happen to bring you down but to teach you lessons on how you will move forward is also a key factor.
I know that these are all better said than done. When faced with failures, our spirit gets crushed to the point where we think we can no longer rise up. During these times, I think seeking help from other people would be best. Talk to the person you trust the most. Sometimes knowing other people's perception of our problems make us realize that it isn't as problematic as we see it.
More importantly, avoid the poison of comparison. This often cause people to lose the motivation, as they think that nothing good ever happens to them while others keep on succeeding. I do believe that there is a right timing for all of us. We have to endure all the pain that failures bring us, and come to a resolve that giving up should never be an option.