在Eclipse中用Maven创建Web工程(tomcat:run 启动)
maven
Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
项目地址:https://gitcode.com/gh_mirrors/ma/maven

·
本文主要描述在Eclipse中用Maven创建Web工程,并用tomcat加载启动工程的操作步骤,其中采用Jetty类似。
一、创建项目
1、Eclipse中用Maven创建项目
2、继续下一步Next
3、选maven-archetype-webapp后,继续Next
4、填写相应的信息,Packaged是默认创建一个包,不写也可以
5、创建好项目后,目录如下:
这时jsp页面报错,查看具体报错信息如下:
The superclass “javax.servlet.http.HttpServlet” was not found on the Java Build Path
原因是缺少servlet-api.jar包
6、在pom.xml中引入servlet-api.jar并保存,如下所示
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.5</version>
<scope>provided</scope>
</dependency>
7、刷新工程,工程不再报错
至此,项目已经创建完毕,下面是配置启动工程
二、配置启动工程
在本次示例中,采用tomcat应用服务器启动,具体操作步骤如下
1、配置pom.xml文件
<build>
<finalName>mavenDemo</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12</version>
<configuration>
<skipTests>false</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat6-maven-plugin</artifactId>
<version>2.0-beta-1</version>
</plugin>
</plugins>
</build>
2、参考本人的另外一篇博客:http://blog.csdn.net/shenhaiwen/article/details/68484865,
在第3步配置Maven Build中的参数中,将jetty改为tomcat即可,如下所示:
3、启动程序,输出日志如下所示,说明启动正常
4、浏览器输入地址:http://localhost:8080/mavenDemo/,访问应用正常




Maven: Apache Maven是一个开源的项目管理和构建工具,主要用于Java项目。适合需要自动化项目构建和依赖管理的开发者。特点包括约定优于配置、易于使用和社区驱动。
最近提交(Master分支:16 天前 )
7872c6d8
Changes:
* update Mimir to latest 0.8.1 version
* update infusers as well
* cache changes (see below)
Cache strategy changes:
* initial build: it is snowballing one cache when build is not about PR
* full (rebuild itself + site with itself) and its build: it is snowballing cache differentiated by OS/JDK when build is not about PR
Current problems: on unchanged POM (ie. new IT added), the dependencies ITs pull from Central will be cached by Mimir, but due "cache hit" the new cache will not get stored. Hence, Mimir caching was basically lost. Also, there was a mixup of caches from PRs and main branches. Finally, matrix jobs were competing for cache store. 1 天前
c999cff6
Accept ONLY documented forms of them.
Fixes #10210 2 天前
更多推荐
所有评论(0)