我们为什么要部署应用程序?

发布于 2024-10-09 12:24:22 字数 190 浏览 0 评论 0原文

我真的不明白这个mvn部署,为什么我们要这样做?

我做

mvn clean install

然后我做

mvn jetty:run

我只是有点困惑为什么我们需要这样做或者我应该偶尔进行部署。

I don't really get this mvn deploy and why do we do it?

I do

mvn clean install

Then i do

mvn jetty:run

I am just bit confused on why do we need to do this or should i do deployment once in a while.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

ゃ人海孤独症 2024-10-16 12:24:22

简而言之,Maven 从本地存储库(通常为 $HOME/.m2/repository)解析工件(您放入依赖项部分的工件)。如果它在本地存储库中找不到该工件,它将查找远程存储库。标准远程存储库是位于 http://repo1.maven.org/maven2 的“中央”存储库。
如果执行“mvn install”,您将告诉 Maven 将您的工件(目标文件夹中的 WAR)复制到本地存储库。现在您的其他 Maven 项目可以解析该工件。
如果您希望其他人能够解析该工件,您需要将其放在远程存储库上。这是通过“mvn deploy”完成的(就像中央存储库一样,您可以创建自己的远程存储库)。

为了部署您的 Web 应用程序,您需要从目标文件夹手动部署 WAR 文件,或者使用 Cargo 等 Maven 插件部署到应用程序服务器。

当 WAR 文件通常不用作其他项目中的依赖项时,将 WAR 文件部署到远程 Maven 存储库有何意义?

我建议在应用程序服务器上部署某些内容之前,先正确发布代码。有一个发布插件可以帮助您做到这一点。除了将其放在远程 Maven 存储库之外,它还标记 SCM 中的当前源(例如 subversion)。现在,您的 Maven 存储库中有一个版本控制的二进制文件,它与 SCM 中的标记版本相匹配。
由于 Maven 存储库具有明确定义的结构,因此可以轻松编写将新版本拉取到生产服务器的脚本。

Simply put Maven resolves artifacts (the ones you put in the dependencies section) from a local repository (typically $HOME/.m2/repository). If it cannot find the artifact in the local repository it will look i a remote repository. The standard remote repository is the "central" repositrory at http://repo1.maven.org/maven2.
If you execute "mvn install" you tell Maven to copy your artifacts (your WAR in the target folder) to the local repository. Now your other Maven projects can resolve the artifact.
If you want others to be able to resolve the artifact you need to put it on a remote repository. This is done with "mvn deploy" (just like the central repository, you can create your own remote repository).

In order to deploy your web application you need to either manually deploy the WAR file from the target folder or use a Maven plugin like Cargo to deploy to the application server.

What is the point of deploying WAR files to a remote Maven repository, when they usually are not used as dependency in other projects?

I would suggest that prior to deploying something on the application server you do a proper release of your code. There is a release plugin that helps you with that. In addition to putting it on the remote Maven repository it tags the current source in your SCM (e.g. subversion). Now you have a versioned binary in your Maven repository that matches a tagged version in your SCM.
Since the Maven repository has a well-defined structure it is easy to write scripts that pull a new version to the production server.

无戏配角 2024-10-16 12:24:22

Maven 部署插件 摘录:

主要使用deploy插件
在部署阶段,添加您的
工件到远程存储库
与其他开发者共享以及
项目。这通常是在一个
集成或发布环境。它
也可用于部署
特定的工件(例如第三个
像 Sun 的非派对罐
可重新分发的参考
实现)。

Maven 安装插件 摘录

安装插件在
安装阶段添加工件
本地存储库

Maven Deploy Plugin Excerpt:

The deploy plugin is primarily used
during the deploy phase, to add your
artifact(s) to a remote repository for
sharing with other developers and
projects. This is usually done in an
integration or release environment. It
can also be used to deploy a
particular artifact (e.g. a third
party jar like Sun's non
redistributable reference
implementations).

versus

Maven Install Plugin Excerpt

The Install Plugin is used during the
install phase to add artifact(s) to
the local repository

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文