Maven clean/install failing

Viewed 274

when I'm trying to clean/install maven following error I'm facing... any suggestions Error: Could not find or load main class Pictures.spring-tool-suite-3.7.1.RELEASE-e4.5.1-win32-x86_64.sts-bundle.sts-3.7.1.RELEASE.configuration.org.eclipse.osgi.24.0..cp.;.D:.Saved

4 Answers

Two ways:

  1. below setting is tested in intellij IDE:
    edit configuration->Configuration->Main class: specify fully qualified path.
  2. you can specify main class through maven plugin in your pom.xml like below:.
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifest>
              <addClasspath>true</addClasspath>
              <mainClass>fully.qualified.MainClass</mainClass>
            </manifest>
          </archive>
        </configuration>
      </plugin>
    </plugins>
  </build>

Can you share your project structure and type ? Is it a spring boot Application ?

Alternatively, you can set you Main class / Main type from IDE

Right click on project -> Run as -> Run configurations -> Add main type or main class here 

Can you try to change line in .classpath

<classpathentry kind="lib" path="C:/Users/ABC/Projects/last.fm-bindings-0.1.1.jar" sourcepath=""/>

Like:

<classpathentry kind="lib" path="last.fm-bindings-0.1.1.jar"/>

Add the following code snippet to your maven build file and be sure to replace fully.qualified.MainClass with the main class in your application.

<build>
  <plugins>
    <plugin>
      <artifactId>maven-assembly-plugin</artifactId>
      <configuration>
        <archive>
          <manifest>
            <mainClass>fully.qualified.MainClass</mainClass>
          </manifest>
        </archive>
        <descriptorRefs>
          <descriptorRef>jar-with-dependencies</descriptorRef>
        </descriptorRefs>
      </configuration>
      <executions>
        <execution>
          <id>make-assembly</id>
          <phase>package</phase>
          <goals>
            <goal>single</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

You can then use mvn clean compile assembly:single to generate an executable jar which can be run without issues.

Further Reading: https://stackoverflow.com/a/574650/15806017

Related