Anjali Huynh

Massachusetts collected $40.8 billion in overall tax revenue for the fiscal year that ended on June 30, with $2.2 billion coming from the state’s so-called “millionaires tax,” state finance officials said Friday.

The total haul was $967 million more than projected, much of which came from the millionaire’s tax — funds that can only be spent on education and transportation.

While the millionaire’s tax revenue was more than double the $1 billion that Governor Maura Healey and other legislators had allocated to spend, the windfall won’t leave state coffers flush with cash.