简体   繁体   中英

How to run a Maven / Gradle web project through command line?

I'm a beginner in Spring. I'm trying to find a command to execute a java web project created with gradle/maven and couldn't find a way. I want to do what eclipse does when I hit the "run on server" button.

For eg. in Django all i'll have to do is python3 manage.py runserver

If its a maven project To execute the Application as java application use

mvn exec:java -Dexec.mainClass="packagename.Mainclass"

If you have tomcat/ninja/jetty plugin in your pom to deploy it as a container use

mvn tomcat7:run       (for tomcat plugin)

If a have an external tomcat container configure pom.xml first. then use

mvn tomcat7:deploy

If you have a jetty plugin use

mvn jetty:run  

but you need to configure the pom.xml for the ip and port for it for the above three

If you are using Spring-boot, Spring Boot Maven Plugin allows you to package and run your application by using the following command:

mvn spring-boot:run

Remember to include the spring-boot-maven-plugin inside your pom.xml as mentioned.

<build>
  <plugins>
   <plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
   </plugin>
  </plugins>
</build>

Read up on Running as a Package Application on how to run with Gradle Plugin. Additional resources See here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM