java 'maven jetty:run' 是如何工作的?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40969724/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How does 'maven jetty:run' work?
提问by freeeze king
what I have learned are:
我学到的是:
- Jetty is a java servlet
- Maven is a build automation tool used primarily for Java projects
- the jetty's url in github is https://github.com/eclipse/jetty.project
- mvn jetty:run is run a web project from pom config
- mvn jetty:run are supported by maven-jetty-plugin
- Jetty 是一个 Java servlet
- Maven 是一个构建自动化工具,主要用于 Java 项目
- github中jetty的url是https://github.com/eclipse/jetty.project
- mvn jetty:run 是从 pom 配置运行一个 web 项目
- mvn jetty:run 由 maven-jetty-plugin 支持
So, next what should I do next?
那么,接下来我该怎么做呢?
And I want to know what happened when I execute the command mvn jetty:run?
我想知道当我执行命令 mvn jetty:run 时发生了什么?
What does it send to jetty when it has being used?
当它被使用时它会发送给码头什么?
采纳答案by chaixxiv
The run goal runs on a webapp that does not have to be built into a WAR. Instead, Jetty deploys the webapp from its sources. It looks for the constituent parts of a webapp in the Maven default project locations, although you can override these in the plugin configuration. For example, by default it looks for:
运行目标在不必内置到 WAR 中的 web 应用程序上运行。相反,Jetty 从其源部署 web 应用程序。它在 Maven 默认项目位置查找 webapp 的组成部分,尽管您可以在插件配置中覆盖这些部分。例如,默认情况下它会查找:
- resources in ${project.basedir}/src/main/webapp
- classes in ${project.build.outputDirectory}
- web.xml in ${project.basedir}/src/main/webapp/WEB-INF/
- ${project.basedir}/src/main/webapp 中的资源
- ${project.build.outputDirectory} 中的类
- ${project.basedir}/src/main/webapp/WEB-INF/ 中的 web.xml
The plugin automatically ensures the classes are rebuilt and up-to-date before deployment. If you change the source of a class and your IDE automatically compiles it in the background, the plugin picks up the changed class.
该插件会自动确保在部署之前重新构建类并保持最新状态。如果您更改了一个类的源代码并且您的 IDE 会在后台自动编译它,则插件会选择更改后的类。
You do not need to assemble the webapp into a WAR, saving time during the development cycle. Once invoked, you can configure the plugin to run continuously, scanning for changes in the project and automatically performing a hot redeploy when necessary. Any changes you make are immediately reflected in the running instance of Jetty, letting you quickly jump from coding to testing, rather than going through the cycle of: code, compile, reassemble, redeploy, test.
您不需要将 webapp 组装成 WAR,从而在开发周期中节省时间。调用后,您可以将插件配置为连续运行,扫描项目中的更改并在必要时自动执行热重新部署。您所做的任何更改都会立即反映在 Jetty 的运行实例中,让您快速从编码跳转到测试,而不是经历以下循环:编码、编译、重新组装、重新部署、测试。
https://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#jetty-run-goal
https://www.eclipse.org/jetty/documentation/9.4.x/jetty-maven-plugin.html#jetty-run-goal