This is how I resolved this issue on my mac mini m4.
In the POM file, find where it mentions the java version. Mine was 17.0.6. Change that to the current sdk that matches the program structure.