简体   繁体   English

构建和部署Java Web项目有什么区别?

[英]What is the difference between building and deploying a Java Web project?

I know that 我知道

Compiling is the act of turning source code into object code. 编译是将源代码转换为目标代码的行为。

Linking is the act of combining object code with libraries into a raw executable. 链接是将目标代码与库组合成原始可执行文件的行为。

Building is the sequence composed of compiling and linking, with possibly other tasks such as installer creation. 构建是由编译和链接组成的序列,可能还有其他任务,例如安装程序创建。

(thanks to Ignacio Vazquez-Abrams ). (感谢Ignacio Vazquez-Abrams )。

But when I want to see my changes in a Java Web project I also have to deploy them (after building). 但是,当我想在Java Web项目中看到我的更改时,我还必须部署它们(在构建之后)。 What does Netbeans do when I deploy my project? Netbeans在部署项目时做了什么?

Your definitions seem to come from the world of native code compilers (C, C++, Pascal, etc). 您的定义似乎来自本机代码编译器(C,C ++,Pascal等)的世界。 In Java, compilation is just the process of turning Java code (text) into Java bytecode which is also a high-level code, rather than object (machine) code. 在Java中,编译只是将Java代码(文本)转换为Java字节码的过程,Java字节码也是高级代码,而不是对象(机器)代码。

Linking in Java happens each time the application runs inside the virtual machine, where symbols in the bytecode are resolved to references to other loaded bytecode. 每次应用程序在虚拟机内运行时都会发生Java链接,其中字节码中的符号被解析为对其他加载的字节码的引用。 So the sequence in java is actually: Compile -> Deploy -> Link -> Run. 所以java中的序列实际上是:编译 - >部署 - >链接 - >运行。

Once running, the JVM may choose to turn the Java bytecode into machine code for direct execution but it can also just interpret the bytecode. 一旦运行,JVM 可以选择将Java字节码转换为机器代码以便直接执行,但它也可以只解释字节码。

In this case deploying just refers to telling the application server where the code is and running the startup code as defined in the application descriptor (eg Servlet and Filter initialization defined in web.xml for webapps). 在这种情况下,部署只是告诉应用程序服务器代码所在的位置并运行应用程序描述符中定义的启动代码(例如,web.xml中web.xml中定义的Servlet和Filter初始化)。

它通知应用程序服务器(例如tomcat)您的应用程序存在,配置它并启动它,以便通过http提供。

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

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