上节课的web已经创建好,但是还不能启动,需要tomcat插件才能启动 先去把D:\maven_idea_project\web01\src\main\webapp\WEB-INF里面的三个文件除了web.xml,另外两个删掉,清空web.xml里面的 内容,把下面的代码粘贴进web.xml里面 再去D:\maven_idea_project\web01\src\main\webapp目录下新建一个文件index.jsp,把下面的html格式的代码粘贴进index.jsp里面

hello maven

打开https://mvnrepository.com/,在里面搜索tomcat maven,下拉找到 Apache Tomcat Maven Plugin :: Integration Tests,点 击下方的小蓝字英文org.apache.tomcat.maven,跳转到新网页,选择第一个 Apache Tomcat Maven Plugin :: Tomcat 7.x,跳转到 新网页,选择2.1版本,跳转到新网页,复制Maven框框里面的代码,如下 org.apache.tomcat.maven tomcat7-maven-plugin 2.1 我们在pom.xml里面的标签里面添加如下 org.apache.tomcat.maven tomcat7-maven-plugin 2.1 80 / 最后,在右侧的maven里面展开并刷新一下,依次点击Plugins>tomcat7>tomcat7:run 打开任意浏览器,输入http://localhost:80/即可访问 每次都要点击tomcat7:run,太麻烦了,我们直接加到右上角绿三角形坐标的方框里面,以后直接点击这个绿色三角形就能运行 首先点击方框,Edit Configuration,出现一个新页面,点击左上角的+,点击maven,弹出一个新页面,Name例如写'启动web服务器', Run写tomcat7:run,Working directory写你的项目位置 ############################################################################################################# 为方便,我把我的pom.xml文件的代码放到下面 4.0.0 war web01 com.huanf web01 1.0-SNAPSHOT junit junit 4.12 org.apache.tomcat.maven tomcat7-maven-plugin 2.1 80 /