I am no longer in aviation. I do not want my A&P license to go dormant. Are there any ways to keep my A&P license active without being in aviation for over two years?
If you are "not in aviation", then I assume you are not working in/around/on airplanes. You are required to keep currency as per 61.53:
§ 65.83 Recent experience requirements.
A certificated mechanic may not exercise the privileges of his certificate and rating unless, within the preceding 24 months -
(a) The Administrator has found that he is able to do that work; or
(b) He has, for at least 6 months -
(1) Served as a mechanic under his certificate and rating;
(2) Technically supervised other mechanics;
(3) Supervised, in an executive capacity, the maintenance or alteration of aircraft; or
(4) Been engaged in any combination of paragraph (b) (1), (2), or (3) of this section.
So the only way you can keep your currency (or regain it after you become non-current) without doing anything in Aviation is to demonstrate to the "Administrator" that you are able to do that work. What this entails is not defined in the CFR's, so will be up to your local FSDO.
Otherwise you can take a few hours a week and do mechanic work, for example you may be able to find a flight club and do some fleet maintenance (exchange it for instruction time or something).
tl;dr; You can't keep your license current without working on airplanes or supervising other mechanics. It would be analogous to keeping your pilots license current without ever flying.