Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain

I have a spring boot project here: https://github.com/jcasbin/jcasbin-springboot-plugin. I encountered the following error in Travis CI:

shell 3.43s$ ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V /home/travis/build/jcasbin/jcasbin-springboot-plugin Picked up _JAVA_OPTIONS: -Xmx2048m -Xms512m Error: Could not find or load main class org.apache.maven.wrapper.MavenWrapperMain The command "eval ./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V " failed. Retrying, 2 of 3. 

It seems that the mvnw command fails. This file is generated by my IDE: IntelliJ IDEA 2018.1. I don't know what it is used for and why does it fail?

I already fired an issue in Spring Boot's github issues here, but Spring project said it's Maven wrapper's issue and pointed me here. I don't quite understand what it means. Is it a Maven bug? How to fix the error then?

like image 417
hsluoyz Avatar asked Apr 30 '18 16:04

hsluoyz


2 Answers

Phil's answer is correct. And here is how to create .mvn directory with needed jar inside.
I found the answer here (https://www.baeldung.com/maven-wrapper)

If you have maven and you want to make maven wrapper working, you need to setup maven wrapper:

mvn -N io.takari:maven:wrapper 

It should create .mvn directory and put needed jar in it.

like image 164
Oleksii Volynskyi Avatar answered Sep 20 '22 09:09

Oleksii Volynskyi


You're missing the .mvn folder in your git repository. You should have a folder called .mvn which contains the files wrapper/maven-wrapper.jar, wrapper/maven-wrapper.properties and jvm.config. Perhaps you missed it because it's a hidden folder.

Try doing git add -f .mvn from the command line then commit and push.

like image 38
Phil Webb Avatar answered Sep 18 '22 09:09

Phil Webb