Bayern Munich held on to edge Stuttgart 3-2 and clinch the first treble in the history of German football.