So here's a new one, for me… I'm working with one of the Spring Boot guides, and getting the
Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain
error when running
./mvnw spring-boot:run
(or any Maven Wrapper command)
That said, I see the wrapper
jar within .mvn
where I would expect it to be.
Has anyone else hit this? It seems like it must be a system-level issue because I've had no issue with this in the past.
Here is the repo I am running this command on: https://github.com/spring-guides/gs-scheduling-tasks.git
Initial project is an empty project so when you run ./mvnw spring-boot:run
in this folder the message is clear and tells you that there is no main class in the project to run as a Spring Boot application.
If you run the command in the complete folder you run the project which has all the logic of the tutorial.
If you cd in the root folder and you run mvnw from inside complete or initial folders you get that message because it is like you cd to a completely irrelevant folder like /test/project (you can try that).
What mvnw does is tries to find and run a .pom file where in all folders except for complete and initial is not present.
I finally figured this out, so posting for posterity:
If the Maven download was corrupted for whatever reason and didn't successfully download (due to loss of connectivity or other reasons), this error will throw.
Mitigation is (within Spring Boot application folder):
rm -rf .mvn
./mvnw spring-boot:run
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With