China's foreign ministry has accused Japan's prime minister of hypocrisy and said he would not be welcome in China after he visited a shrine honouring Japan's war dead.

Japanese prime minister Shinzo Abe's visit to the Yasukuni shrine in central Tokyo had seriously hurt relations between the countries and shut the door for dialogue between their leaders, ministry spokesman Qin Gang said.

"Abe's hypocrisy in his claims of prioritising relations with China and hopes for dialogue with the Chinese leaders has been fully revealed," Mr Qin said.

Japanese politicians' visits to Yasukuni have long caused friction with China and both Koreas. The 2.5 million war dead enshrined there include 14 class A war criminals - national leaders who were either executed or died in prison or during their trials. Japan colonised Korea and occupied parts of China, often brutally, before and during the Second World War.

Mr Abe said he did not intend to hurt the Chinese and Korean people's feelings and said that Japan must never wage war again.