一、给 tomcat 添加用户名、密码
在安装目录/cong/tomcat-user.xml中添加以下配置
<role rolename="manager-gui" /> <role rolename="manager-script" /> <user username="tomcat7" password="tomcat7" roles="manager-gui, manager-script" />
二、在 maven 项目中添加 tomcat 插件
1. 在 pom.xml 中添加插件和依赖
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <path>/</path> <server>tomcat8</server> <username>tomcat</username> <password>tomcat</password> </configuration> </plugin>
<dependency> <groupId>org.apache.tomcat</groupId> <artifactId>tomcat-servlet-api</artifactId> <version>8.5.4</version> </dependency>
三、startup.bat 启动服务器 再右击项目>run as>maven build...
注:tomcat6插件名前为tomcat6 7/8为tomcat7