With the rapid development of the next-generation mobile network, the number of terminal devices and applications is growing explosively. Therefore, how to obtain a higher data rate, wider network coverage and higher resource utilization in the limited spectrum resources has become the common research goal of scholars. Device-to-Device (D2D) communication technology and other frontier communication technologies have emerged. Device-to-Device communication technology is the technology that devices in proximity can communicate directly in cellular networks. It has become one of the key technologies of the fifth-generation mobile communications system(5G). D2D communication technology which is introduced into cellular networks can effectively improve spectrum utilization, enhance network coverage, reduce transmission delay and improve system throughput, but it would also bring complicated and various interferences due to reusing cellular resources at the same time. So resource management is one of the most challenging and importing issues to give full play to the advantages of D2D communication. Optimal resource allocation is an important factor that needs to be addressed in D2D communication. Therefore, this paper proposes an optimization method based on the game-matching concept. The main idea is to model the optimization problem of the quality-of-experience based on user fairness and solve it through game-matching theory. Simulation results show that the proposed algorithm effectively improved the resource allocation and utilization as compared with existing algorithms.