当我们构建 java web 项目时会发生什么

发布于 2024-11-14 21:19:04 字数 1438 浏览 5 评论 0原文

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

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

发布评论

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

评论(3

野稚 2024-11-21 21:19:04

1) META-INF 的用途是什么?

2) Maven 创建目标文件夹给你。默认情况下,所有 Maven 插件都将其工作转储到这里。

3) Maven 有从其中排除文件的机制。

理解 Maven 的关键是 Maven 遵循约定。这意味着,如果您根据 Maven 的期望构建项目,Maven 会非常好地完成很多事情,而您几乎不需要付出任何努力。例如,这就是区分源目录中的 Java 类和资源的方式:

src/main/java/com/mycompany/MyObj.java  
src/main/resources/my/company/spring.context.xml  
src/test/java/com/mycompany/MyObjTest.java  
src/test/resources/my/company/spring.context.xml

当您运行 mvn test 时,它将编译所有内容,将其适当移动到目标文件夹,加载 JUnit 运行程序并为您提供一个类路径,让 Spring 可以轻松访问测试文件夹下的 spring 上下文。它将运行测试并将报告置于目标之下。

Maven 不像 Ant。在 Ant 中,你必须告诉它一切。 Maven 的工作原理正好相反,它会默认假设一切,直到您另行通知为止。

1) What's the purpose of META-INF?

2) Maven creates the target folder for you. It's where all of the Maven plugins dump their work by default.

3) Maven has mechanisms for excluding files from it.

The key to understanding Maven is that Maven works on conventions. That means that Maven will do a lot of things really well with almost no effort on your part if you structure your project according to Maven's expectations. For example, this is how you differentiate between Java classes and resources in the source directory:

src/main/java/com/mycompany/MyObj.java  
src/main/resources/my/company/spring.context.xml  
src/test/java/com/mycompany/MyObjTest.java  
src/test/resources/my/company/spring.context.xml

When you run mvn test it will compile all of that, move it appropriately over to the target folder, load the JUnit runner and give you a classpath that will let Spring have easy access to the spring context under the test folder. It'll run the tests and drop the reports under target.

Maven is not like Ant. In Ant, you have to tell it everything. Maven works on the opposite end in that it assumes everything by default until you tell it otherwise.

无尽的现实 2024-11-21 21:19:04

这是一个常见问题,因为 java 已经变得如此庞大。通常很难区分一种技术从哪里结束,另一种技术从哪里开始。您需要熟悉您正在使用的所有各种组件的文档。

例如,如果您有一个“目标”文件夹,那么我假设您正在使用 maven。 Maven 是一个用于依赖管理的 java 实用程序。当你“mavenize”一个项目时,你同意遵守一系列标准,maven 反过来会为你做很多繁重的工作(编译代码、查找依赖库和运行测试)。 maven 所做的部分工作是创建标准 maven 目录,在本例中“目标”

更多 maven 信息 - http://maven.apache。 org/

至于 META-INF,这是 Java EE 规范的一部分。它确实有一个关于打包和部署的目的,但您通常不会发现自己经常使用它。大体上和maven的原理是一样的。您遵守 Java EE 标准,并且符合 Java EE 的工具会为您完成大部分工作。

有关详细信息,请查看此链接 - http://java.sun.com /blueprints/guidelines/designing_enterprise_applications/packaging_deployment/index.html

一般来说,要理解这些内容,您应该查看一些有关 Java EE 的教程并参考您的容器的示例和文档。

This is a common problem because java has grown so big. Its often hard to tell where one technology ends and another begins. You need to familiarize yourself with the documentation for all the various components you are using.

For instance, if you have a 'target' folder then I assume you are using maven. Maven is a java utility used for dependency management. When you 'mavenize' a project, you agree to adhere to a bunch of standards and maven in turn does a lot of the grunt work for you(compiling code, finding dependent libraries, and running tests). Part of what maven does is create standard maven directories in this case 'target'

more maven info - http://maven.apache.org/

As for META-INF this is part of the Java EE spec. It does have a purpose concerning packaging and deployment, but you'll generally not finding yourself using it very often. Its generally the same principle as maven. You adhere to the Java EE standard and the Java EE compliant tools do most of the work for you.

For more info look at this link - http://java.sun.com/blueprints/guidelines/designing_enterprise_applications/packaging_deployment/index.html

In general to understand these you should check out some tutorials on Java EE and refer to your container's examples and documentation.

妄司 2024-11-21 21:19:04

1) META-INF 的用途是什么
2-3)目标文件夹创建Macven,它管理所有依赖项等: one< /a>, 两个

1) What is the purpose of the META-INF
2-3)Target folder creates Macven, it manages all dependensies, etc: one, two

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