Could not find MavenWrapperMain class, but is contained in .m2 in the directory

So, for me, a new one ... I work with one of Spring's download guides and get

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

at startup

 ./mvnw spring-boot:run 

(or any Maven Wrapper command)

However, I see a jar wrapper inside .mvn where I would expect this.

Has anyone else hit this? This seems to be a system level issue, because in the past I had no problems with this.

Here is the repo, I run this command: https://github.com/spring-guides/gs-scheduling-tasks.git

+5
source share
4 answers

I finally figured it out, so I'm sending it to posterity:

If the Maven download was corrupted for any reason and was not successfully downloaded (due to loss of connection or for other reasons), this error will be generated.

Softening (in the folder with the Spring boot application):

 rm -rf .mvn ./mvnw spring-boot:run 
+1
source

The initial project is an empty project, so when you run ./mvnw spring-boot:run in this folder, the message becomes clear and says that the project does not have a main class to run as the Spring boot application.

If you run the command in the full folder, you run the project, which has all the tutorial logic.

If you enter the root folder and run mvnw from internal or source folders, you get this message because it looks like you are cd to a completely unnecessary folder, for example / test / project (you can try this).

That mvnw is trying to find and run the .pom file, where in all folders except the full and initial, no.

+4
source

try to remove it from the .m2 directory and rebuild again, I once had a similar problem and was only solved when I removed the jar from .m2 and restored it again.

0
source

You need to add configuration

 <configuration> <mainClass>${start-class}</mainClass> <layout>ZIP</layout> </configuration> 

https://docs.spring.io/spring-boot/docs/current/maven-plugin/usage.html

It is presented in the full directory, but does not have a class or annotated class (as an option instead of a configuration section)

Just finished "full" on Windows

 [INFO] Installing D:\projects\edu_test\gs-scheduling-tasks\complete\pom.xml to C:\Users\alex\.m2\repository\org\springframework\gs-scheduling-tasks\0.1.0\gs-scheduling-tasks-0.1.0.pom [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS 
0
source

Source: https://habr.com/ru/post/1275344/


All Articles