In most recent years, teams have figured out that they can use -- or misuse, if you would -- Long Term Injured Reserve to override the principals of the cap. (My guess is that with LTIR abuse compounding year-after-year by more and more teams, there will be some kind of change to the rules during the next CBA negotiations).
Another popular bypass for teams in the last several years has been engaging a third-party broker to assist with "making the money work" to get deals done. That is to say that teams with cap space to spare take on money (contracts) for teams who don't and receive an asset for their cooperation. The recent trade between the Toronto Maple Leafs and the Arizona Coyotes is a perfect example:
Toronto is up against the cap and wanting to make a run at the Stanley Cup, so they need to free up some space.
Nick Ritchie hasn't turned out to be what the Leafs thought when they signed him in the off-season and the Leafs want to get rid of him and his hefty salary and use it towards a player or players that can have more positive influence than Ritchie.
Arizona has plenty of cap space available as they are in a complete (some might say perpetual) rebuild, so they take Ritchie and his contract -- even though neither they nor any other team in the League claimed him when the Leafs waived him -- with a 2nd Round pick from the Leafs as a sweetener. Sure, they sent Ilya Lyubushkin and Ryan Dzingel the other way, but both were on expiring contracts and the math of dumping their contracts and taking on Ritchie's was something Arizona GM Bill Armstrong decided they should do and they got a 2nd Rounder out of the deal, too.
Arizona's roster, by the way, is riddled with players that they've acquired from other teams in previous seasons as a result of similar brokering. Loui Eriksson, Andrew Ladd, Anton Stralman, Shayne Gostisbehere, Jay Beagle and so on. When a team has a bad contract that they want to get rid of (like the Leafs did Ritchie's), they call the Coyotes.
Another way of doing this revolves around getting a third team involved in trade proposals between willing two willing trade partners for the purpose of retaining salary on a player in exchange for a pick or a prospect before sending the player to the intended recipient.
Check out the link below in which Daily Faceoff's Chris Gear provides an excellent, comprehensive look at the ins and outs of third-party brokering in today's NHL and the effect that it'll have on trade season: