How do I get over him?

I've been completely infatuated with one of my close friends for almost two years now. I have tried so many different things to get over him but nothing has worked. I can see a future with him and basically can't imagine my life without him, but I know he doesn't feel the same way about me. My main issue is that whenever I'm getting over him, he flirts with me a little or we hang out and I get sucked back in.

What do I do!!