tomcat配置热部署(maven插件配合热部署)

1、热部署是指在tomcat运行的时候发布新的web项目到tomcat上,使用tomcat后台进行项目的热部署发布,访问http://ipaddr:8080


2、访问后台的时候我们需要进行登录验证,这里我们需要配置用户(如果访问了点击取消,会出现401未授权页面,上面有用户的相关配置)


3、配置tomcat后台用户说明,步骤如下:(第4步为具体配置)

1)找到这个文件 conf/tomcat-users.xml

2)配置后台网页版用户的权限(例子)

<role rolename="manager-gui"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>
3 )配置权限说明

manager-gui - allows access to the HTML GUI and the status pages

manager-script - allows access to the text interface and the status pages

manager-jmx - allows access to the JMX proxy and the status pages

manager-status - allows access to the status pages only  

求助了谷歌大神:2333

manager-gui - 允许访问HTML GUI和状态页面

manager-script - 允许访问文本界面和状态页面

manager-jmx - 允许访问JMX代理和状态页面

manager-status - 仅允许访问状态页面

4)我们如果用到了maven的热部署,则需要给该用户配置manager-script权限


4、我使用到了网页和maven插件的热部署,配置如下

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<user username="tomcat" password="tomcat" roles="manager-gui,manager-script"/>


5、重启tomcat,然后访问网页tomcat的后台


6、网页热部署



7、使用maven热部署,配置如下:

<build>
		<plugins>
			<plugin>
				<groupId>org.apache.tomcat.maven</groupId>
				<artifactId>tomcat7-maven-plugin</artifactId>
				<configuration>
					<path>/</path>
					<!-- 这里的ip和端口号是访问tomcat首页的端口 -->
					<url>http://192.168.25.135:8080/manager/text</url>
					<username>tomcat</username>
					<password>tomcat</password>
				</configuration>
			</plugin>
		</plugins>
	</build>

8、执行maven命令 (clean tomcat7:redeploy -DskipTests)这样就可以吧项目部署到对应的服务器上了


9、通过浏览器访问到对应的项目路径,注意:再发布的时候,项目中的localhost路径需要更改为对应的服务器路径




猜你喜欢

转载自blog.csdn.net/qq_31489805/article/details/78241371