为什么我在这个 Java 动态 web 项目中没有看到任何 main 方法? [英] Why don't I see any main method in this Java dynamic web project?

查看:52
本文介绍了为什么我在这个 Java 动态 web 项目中没有看到任何 main 方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图了解 Web 服务的工作原理,但我遇到了 本教程.

I was trying to understand how the Web Services work and I came across this tutorial.

现在,我已经看到 Spring 在企业应用程序中使用,并且总是想知道主要方法在哪里以及一切如何工作?每当我去参加 Spring 教程时,他们都会从 beanFactory 和 Contexts 开始,而不是什么,所有这些都在一个主要的 Java 方法中,然后继续根据需要获取 bean.这与我在应用程序中看到的完全不同.

Now, I've seen Spring being used in enterprise applications and always wondered where the main method was and how everything worked? And whenever I would go to a Spring tutorial they'll start with beanFactory and Contexts and what not, all in a main Java method and from there just keep getting beans as required. This is totally different from what I see in the applications.

在这种情况下,Spring 究竟是如何工作的?调用顺序是什么?我想某处会有一些隐藏的主要方法,但我不确定.

How exactly does Spring work in this case? What is the sequence of calls? I guess there will be some hidden main method somewhere, but I am not sure of that.

通常,如果我要从命令行运行一个简单的 Java 项目,我会执行 java mainClass.现在在这种情况下会如何发生?

Normally if I were to run a simple Java project from command line, I'd do java mainClass. Now how would it happen in this case?

推荐答案

Web 应用程序没有 main;正在运行的程序"实际上是 Web 容器(Apache Tomcat、Glassfish、JBoss、Weblogic 等),该程序将为您部署到其中的 Web 应用程序提供服务.您可能需要阅读 JEE 教程来学习和了解什么是 Java Web 环境.

Web applications don't have a main; the 'program' that is running is actually the web container (Apache Tomcat, Glassfish, JBoss, Weblogic, whatever) and that program will service the web application(s) you deploy into it. You might want to read the JEE tutorial to learn and understand what a Java web environment is.

https://docs.oracle.com/javaee/7/tutorial/

这篇关于为什么我在这个 Java 动态 web 项目中没有看到任何 main 方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆