1.选择建立maven project项目

点击 new——other——maven project,点击next。


2.选择项目路径,使用默认的路径:Use default Workspace and location



3.选择项目类型,选择maven-archetype-webapp类型。



4.输入groupId、artifactId、version、package(会默认给你一个package,不写也可以)、点击finish。



5.若出现如下错误:


在cmd中使用 mvn archetype:generate重新运行一下,然后重启eclipse即可解决。


6.刚建好的文件结构如图所示:



7.配置项目,需要添加三个source folder,分别是src/main/java   src/test/java  src/test/resources. 注意此处应该new--

Source folder


8,更改class 路径,右键点击项目,java-build path--source,双击Output folder:选择路径

src/main/java, src/main/resources 选择target/classes

src/test/java, src/test/resources 选择target/test-classes;

同时可以order and export更改文件夹显示顺序、更改项目jdk


9.将项目改成Dynamic Web项目,右键项目,选择Project Facets,点击Convert to faceted from。。。



10.我使用的jdk1.8,配置如下:



11.配置完后我这边有报错:

  

The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

解决方法:在错误的项目上单击右键》build path》configure build path》add library》server runtime》

apache tomcat x》点击ok


12.完成后此时项目结构树应该增加了webContent文件夹,将webcontent下的两个文件夹cope到src/main/webapp

下合并,并且删除webContent文件夹,完成后如图所示:



13.右键点击项目,以此点击Properties》Deployment Assembly,如图所示:


通过remove删掉src/test/java, src/test/resources, /webContent,并且通过add添加webapp与maven依赖如下图所示,



14.将项目添加到server中运行


完。


GitHub 加速计划 / ma / maven
36
2
下载
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:1 个月前 )
8f63dcca Maven now fails with a clear error message when a POM contains mixins but consumer POM flattening is disabled. Mixins require model version 4.2.0 and cannot be part of the consumer POM, so they must be removed during transformation through flattening. Changes: - Added validation in DefaultConsumerPomBuilder to check for mixins when flattening is disabled and throw MavenException with helpful message - Added integration test MavenITgh11456MixinsConsumerPomTest with three scenarios The error message guides users to either enable flattening by setting maven.consumer.pom.flatten=true, using preserve.model.version=true, or remove mixins from their POM. Fixes https://github.com/apache/maven/issues/11456 1 天前
dff79033 Bumps [net.bytebuddy:byte-buddy](https://github.com/raphw/byte-buddy) from 1.18.1 to 1.18.2. - [Release notes](https://github.com/raphw/byte-buddy/releases) - [Changelog](https://github.com/raphw/byte-buddy/blob/master/release-notes.md) - [Commits](https://github.com/raphw/byte-buddy/compare/byte-buddy-1.18.1...byte-buddy-1.18.2) --- updated-dependencies: - dependency-name: net.bytebuddy:byte-buddy dependency-version: 1.18.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 1 天前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐