实际环境:elipse neon + maven 3.5.0 +tomcat 8.0.44
1,手动部署
project右键-->Run As--->Maven install
生成war文件
此后的步骤跟手动export war文件再部署一样
2,自动部署
需做以下配置:
step1:配置tomcat8用户
修改文件.\conf\tomcat-users.xm
<role rolename="tomcat"/>
<role rolename="role1"/>
<role rolename="admin"/>
<role rolename="admin-gui"/>
<role rolename="manager"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="lyyj" password="123456" roles="tomcat,role1,admin,admin-gui,manager,manager-gui, manager-script"/>
step2:在web项目的pom.xml配置需要下载的jar包和插件
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.deploy>deploy</project.deploy>
<project.tomcat.version>8.0.44</project.tomcat.version>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>com.lyyj.hibernate</groupId>
<artifactId>hellohibernate</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>hellohibernate Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet.jsp</groupId>
<artifactId>jsp-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.tomcat</groupId>
<artifactId>tomcat-servlet-api</artifactId>
<version>${project.tomcat.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<finalName>hellohibernate</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
</plugin>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<url>http://localhost:80/manager/text</url>
<server>tomcat</server>
<username>lyyj</username>
<password>123456</password>
</configuration>
</plugin>
</plugins>
</build>
step3:启动tomcat8 .\startup.bat
step4:部署webapp到tomcat server,命令行切换到project目录,执行命令:mvn tomcat7:deploy