简体   繁体   English

如何通过命令行运行Maven / Gradle Web项目?

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

I'm a beginner in Spring. 我是Spring的初学者。 I'm trying to find a command to execute a java web project created with gradle/maven and couldn't find a way. 我试图找到一个命令来执行使用gradle / maven创建的Java Web项目,但找不到方法。 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 在Django中,我要做的就是python3 manage.py runserver

If its a maven project To execute the Application as java application use 如果它是一个maven项目要以Java应用程序的身份执行Application,请使用

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

If you have tomcat/ninja/jetty plugin in your pom to deploy it as a container use 如果您的pom中有tomcat / ninja / jetty插件,可以将其部署为容器使用

mvn tomcat7:run       (for tomcat plugin)

If a have an external tomcat container configure pom.xml first. 如果有外部tomcat容器,请先配置pom.xml。 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 但是您需要为以上三个配置ip和端口的pom.xml

If you are using Spring-boot, Spring Boot Maven Plugin allows you to package and run your application by using the following command: 如果您使用的是Spring-boot,则Spring Boot Maven插件允许您使用以下命令打包和运行应用程序:

mvn spring-boot:run mvn spring-boot:运行

Remember to include the spring-boot-maven-plugin inside your pom.xml as mentioned. 请记住,如前所述,在pom.xml包含spring-boot-maven-plugin。

<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. 阅读有关作为软件包应用程序运行的信息,以了解如何使用Gradle插件运行。 Additional resources See here . 其他资源请参见此处

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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