under the Military Code and under general law, no military officer can obey an order that is not legal. Basically, it completely prevents Trump from issuing a legal order to invade Greenland.
Nothing is stopping him from issuing an illegal order and his generals would be in more hot water by disobeying it than obeying it.
Any military is purpose built to remove individual autonomy. The ones who rise to the top are the ones who most believe in the chain of command. The idea that one of our generals (who have been purged during Trump's second term) would disobey an order is laughable to me. Maybe every modern president has used the military in a way that is illegal according to US law, a treaty, or both.