Elidjon Dedaj, 24 and Kujtim Qungeli, 37, both of no fixed address, appeared at Southampton Crown Court having pleaded guilty to producing a controlled drug of Class B – Cannabis in April.
Both were sentenced to 12 months in prison, and the judge ordered for the seized drugs to be destroyed.
Officers on patrol on 19 March this year spotted a white van facing the wrong way in a one way system in Alfred Street.
When Dedaj and Qungeli, who were near the van, saw the officers they tried to run away but were detained nearby.
Qungeli had been seen going into a property in Alfred Street before officers detained him.
A search of the address revealed a large quantity of cannabis being grown under high powered lights and evidence of a substantial fire that had occurred near the fuse box.
Dozens of bin bags filled with cannabis were seized, believed to have a street value of £352,000.
PC Jess Swift from Western Investigations was the officer in the case.
She said: “Drug cultivation and supply often goes hand in hand with organised crime, serious violence including use of firearms and the exploitation of vulnerable individuals and children – which is why tackling the issue is one of our priorities.
“The electricity needed to grow this many plants can also be a huge fire risk, putting neighbouring properties and lives in danger.
“By dismantling this cannabis factory and taking Dedaj and Qungeli off the streets, we have disrupted the local drug supply network and made Southampton a safer place to live.
“I hope this sentence encourages people to come forward and report information about any potential cannabis cultivation or drug supply in your neighbourhood.
“All the information you give us is reviewed and helps us to take action.”