Eclipse安装好m2e插件,使用Maven构建项目后,启动web项目就行就非常简单了,你不再需要下载然后在eclipse中配置tomcat。
- 右键你的项目 -> Run As -> Run Configurations...
- 双击左侧的Maven Build,会出现一个New_configuration
- Name改成自己想要的名字,Browse Workspace选择要启动的web项目,Goals填写tomcat:run
- Apply并Run即可。首次执行按如上设置,以后执行按如下图操作启动即可:
pom.xml的project节点中的build节点如下:
<build> <finalName>basic</finalName> <outputDirectory>D:\webapps</outputDirectory> <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> <includes> <include>**/*Test.java</include> </includes> <excludes> <exclude>**/Test*.java</exclude> </excludes> </configuration> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat6-maven-plugin</artifactId> <version>2.0-beta-1</version> </plugin> </plugins> </build>
时间: 2024-10-12 15:30:59