And for good reason, because military strategy, logistics and philosophy evolved quite a bit from 1812 to 1940.
It's true that Hitler generally only listened to the generals that agreed with him anyway (most notably brushing aside Ludwig Beck's very serious warnings against a war over the Sudetenland), but prior to 1944, he did listen to the OKH when its objections were unanimous, which they would've been over invading Spain. Unlike France, which could be defeated by blitzing across the flat Low Countries and capturing their armies, Spain is mountainous (especially in the north) and decentralized. Furthermore, unlike France, for which occupation was a necessity due to its danger as a Great Power, there would simply be no reason at all to invade Spain, even if they did join the Western Allies. Spain did not have enough factories to warrant any sort of occupation, and it only would have overextended Germany's already painfully resource-sucking Atlantic Wall. Alternatively, the Axis could have invaded for the sake of putting Franco on their leash and "Vichyizing" Spain, but that would have been even stupider since it would just open up the entire peninsula for counter-attack from the Western Allies.
In short: there was nothing to be gained from invading Spain, especially considering the necessary resources to do so.