Although some people here think that the Opium wars ruined Imperial China, actually Imperial China did recover, what ruined imperial China was the massive defeat of the First Sino-Japanese War which opened up China to Japanese military aggression and also started a string of conflicts with European power who also wanted a bit of the cherry. Imperial China fell soon after the war.
The war itself could have been avoided, but I think that soon Japan and China would have still come to blows, if not over Korea then somewhere else. Japan was keen to expand, and China was in her way. I think we can presume that in a short time, these two powers are going to come to blows.
The other problem is that the Chinese leadership was overconfident, it thought it could hold on its own militarily successfully against Japan. What it turned out was that the Chinese defeat was due mainly to poor morale, poor leadership both political and militarily rather than equipment.
So let us say that the Chinese leadership sees reality and decides much earlier that it needed to make an alliance with a Western Power to survive. It then selects Russia in exchange for commercial and possibly land concessions. China then integrates its military in with Russia.
Japan might then think twice about getting in a war with China, if it did China and Russia should be able to hold Japan long enough as Japan cannot last a prolonged conflict.