There was apparently some sentiment in the USA for a war against Spain in the 1870s, as a result of the Virginius Affair.
IOTL one of the factors that averted a conflict was that a Spanish ironclad was on a visit to New York when the news broke and the Americans realised that their navy didn't have anything that could face such warships...
Have that ship not arrived yet, and an American declaration of war made. Any American attempt to take Cuba gets roughly handled, even though there's a small rebellion (by a group of pro-slavery landowners, with whom the USA would find it difficult to side openly, as it happens...) in progress on one end of the island, and the Spanish navy easily sinks whatever forces the USN tries to throw against it then blockades or even bombards American ports until the US government sues for peace.
Reparations for the initial American attacks would be required, I think, but presumably it would be too late for a restoration of Spanish rule over Florida.
Of course, this presumes that the USA can't talk the UK into an alliance for at least the duration of that war...