3

Required Configuration for running maven project from command line.

1 Answers1

1

Very Nice question. I had also stuck with same question but I have found solution. Required two maven plug-ins which are given under. Please make sure your JDK 1.7 and JRE 7 version is configure in your project. Add this plugin to your pom.xml and follow this step:

1 mvn clean

2 mvn install

3 mvn exec:java

Step 3 is required to run project without specify main class

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.2</version>
                 <configuration>
                         <source>1.7</source>
                         <target>1.7</target>
                         <encoding>${project.build.sourceEncoding}</encoding>
                         <showDeprecation>true</showDeprecation>
                         <showWarnings>true</showWarnings>
                         <executable>${env.JAVA_HOME}/bin/javac</executable>
                         <fork>true</fork>
                 </configuration>
            </plugin>
            <plugin>  
                   <groupId>org.codehaus.mojo</groupId>  
                   <artifactId>exec-maven-plugin</artifactId>  
                   <version>1.2.1</version>  
                   <configuration>  
                      <mainClass>com.mainClass</mainClass>  
                   </configuration>  
             </plugin> 
Sagar007
  • 848
  • 1
  • 13
  • 33