This work presents a resilient distributed optimization algorithm based on the event-triggering mechanism for cyber–physical systems (CPSs) to optimize an average of convex cost functions corresponding to multiple agents under adversarial environments. Two attack scenarios, including the f-total (each agent is affected by at most f malicious agents in the whole network) and the f-local (each agent is affected by at most f malicious agents in its in-neighbor set) attacks are considered. Subsequently, the convergence conditions under these two attack scenarios are provided, respectively, both of which guarantee that the state values of benign agents converge to a bounded error range. The optimality conditions are also presented by theoretical analysis, which guarantee that the state values of benign agents converge to a safety interval constructed by local optimal values under certain graph conditions, despite the misbehavior of malicious agents. In addition, four numerical examples are presented to show the effectiveness and superiority of the event-triggering resilient distributed optimization (RDO-E) algorithm. Compared to existing resilient algorithms, the proposed method achieves resilient distributed optimization with higher accuracy and less demanding communication overheads. Finally, by applying the proposed method to the multi-microgrid system, a resilient economic dispatch problem (REDP) is successfully solved, which validates the practical viability of the RDO-E algorithm.