Trade was seldom actually discouraged in ancient China.
But the significance of merchants were oft understated in historical accounts.
There were, at various times, restrictions to prevent citizens from trading with foreigners, but most of the time, these restrictions were ignored and traders simply bribed the border guards as well as officials in the Court.
Reasons for restrictions varied. Sometimes it was due to official hostilities and the Court was more intent on preventing espionage rather than trade itself.
Sometimes there were restrictions due to nature of goods, such as state monopoly on iron and salt, as well as preventing merchants from selling weapon-grade iron to rival powers.
Ming Dynasty's restrictions were due to certain amount of xenophobia of the officials in the Imperial Court - many Japanese and European maritime traders were blamed for piracies, which a certain number of them were actually responsible for.
Apart from traditional low status accorded to merchants, officials also viewed them as hard-to-control group of people who had disproportionate amount of wealth compared to their numbers. Wealth was a source of power, and most officials, with little knowledge of commerce, found themselves unable to control merchants the way they controlled peasants.
Unlike peasants, merchants' wealth was not tied to the land, nor to particular cities. The market forces are very fluid and dynamic, and with little understanding of the market economy, officials were oft outsmarted by merchants whose quick minds enabled them to get round restrictions and tariffs, moving their wealth from one place to another quickly and leave the officials in the dust.