Whiners are one of the most frustrating people to have to deal with and be around. It is not uncommon to be extremely bristled by this behavior. Often you want to stay with the tactful route to get your points across to people like this. But it is hard not to be tempted to just tell the whiner to suck it up and deal with it.
Whining about how bad life is treating you is not an endearing quality. It will actually tend to repulse people from you if you act this way. But if you have the misfortune of actually having to try to deal with a person of this calibre, you will need to know a few good coping tips.
First of all, realize that the whiner is insecure about themselves and wants attention. More than that, they want validation. Giving them what they want is only going to reinforce the whining. When a person with a difficult personality sees that their whining gets them reassuring remarks and metaphorical shoulder patting, they will continue to seek out this form of validation.
You would do best not to reinforce this type of behavior.
Do not pay them attention. Do not feed their attention seeking. The next time someone you know starts this nonsense, use sense and respectfully tell them you are excusing yourself from the conversation. You cannot dictate what whiners say, but you can control your own directives. Walking away from a scene should not be considered weakness or a retreat. You do not want to engage this personality. If you do you are only enabling them to continue whining to someone who will listen. Removing yourself from the scenario gives them no listener.
Removing yourself from the situation also gives you relief from not having to listen to the constant negative drone of a whiner. You have to remember that their behavior is negatively impacting you, otherwise it would not annoy you.
Do whatever you have to in order to get away from that person. Go for a run. Talk to someone who supports you. Meditate. You do not have to be subjected to ceaseless whining. You do have the option, always, to leave. If more people did this, when dealing with a negative personality, that person might begin to realize that their behavior was serving no purpose in gaining an audience, or attention. They would stop. Either way, it is always your choice, and your mental health and sanity deserves to be respected.