Energy efficiency is an extremely important performance indicator for device-To-device communications due to the limited battery capacity of user equipments (UEs). In this paper, we focus on the two-stage EE optimization problem, which consists of a channel and power allocation problem in the first stage, and a context-Aware D2D peer recovery problem in the second stage. We incorporate a many-To-one matching framework to solve the nonconvex combinatorial problem with dynamically varying preferences. At each iteration of the first-stage match, D2D transmitters and cellular UEs are firstly matched by assuming that the preferences remain unchanged, which are used later to update the preferences. The second-stage matching problem between D2D transmitters and receivers can also be solved by the proposed algorithm with little modifications. We validate the proposed algorithm through numerical results and compare it with several heuristic algorithms.