In this work, a smart self-healing coating with long-term anticorrosion ability was developed based on multiresponsive polyaniline (PANI) porous microspheres. The polyaniline porous microspheres loaded with corrosion inhibitor (benzotriazole, BTA) was prepared by the emulsion template method and photopolymerization. The BTA loaded in the polyaniline microspheres acted as a corrosion inhibitor, while the polyaniline in the shell performed the multiple functions of corrosion inhibition, pH-responsive and photoresponsive release, and photothermal conversion. Owing to the inherent corrosion-inhibiting nature of BTA and PANI, the BTA-loaded polyaniline microsphere could endow coating with dual anticorrosive properties. The coating with polyaniline microspheres did not show any corrosion product after 700 h of salt spray testing, while obvious pitting corrosion could be observed for the blank coating after 100 h of the salt spray test. Thanks to the photothermal properties of PANI, the composite coating exhibited self-healing behavior under NIR light irradiation. The coating with 10 wt % polyaniline microspheres could achieve rapid closure and recover its barrier properties within 5 s of NIR irradiation. And the release of BTA could form a passivation film on scratches to further repair coating defects. The on-command responsive release, high healing efficiency, and excellent anticorrosion properties of this dual self-healing anticorrosion coating provide perspectives on extending the service life of metals.