President Donald Trump on Wednesday downplayed the possibility of a dialogue with North Korea in a defiant tweet.

"The U.S. has been talking to North Korea, and paying them extortion money, for 25 years," the president wrote. "Talking is not the answer!"

His comment follows the test of a North Korean missile this week that flew over Japan in what the U.S. and its allies have called a major provocation. The launch yet again puts the nations aiming to stop North Korea's nuclear program in a difficult spot.

Trump on Tuesday said "all options are on the table" in response to Pyongyang's latest test. With the Wednesday morning tweet, he aimed to signal he is not in favor of one of those options, talks to try to get North Korea to back off its nuclear and missile programs.

Later Wednesday, one of Trump's top advisors downplayed the president's tweet on North Korea.

"We're never out of diplomatic solutions," Defense Secretary Jim Mattis told reporters at the Pentagon during a meeting with South Korea's defense minister.

The U.S. and its allies have sought a diplomatic solution to curb the isolated nation's aggression, enacting both unilateral and multilateral sanctions. In particular, they have sought to apply economic pressure through China, North Korea's only major ally.

On Sunday, before the latest missile test, Secretary of State Rex Tillerson said the U.S. is "going to continue our peaceful pressure campaign" to see if it can bring North Korea to "the negotiating table." Trump has publicly contradicted Tillerson before.

On Tuesday, the United Nations Security Council condemned the missile launch but stopped short of endorsing new sanctions. Earlier this month, the organization unanimously applied new sanctions on North Korea.

Earlier Tuesday, Nikki Haley, U.S. ambassador to the United Nations, said "something serious has to happen" in response to the test.

Separately this month, the U.S. Treasury applied new sanctions on Chinese and Russian individuals and entities, aiming to put more pressure on North Korea.