Maven 修改tomcat运行版本和端口,使用Maven发布项目

maven默认是使用tomcat6跑项目的,这段是让maven用tomcat7/8去跑
在pom.xml中添加

 tomcat7

<build>
		<!-- we dont want the version to be part of the generated war file name -->
		<finalName>${project.artifactId}</finalName>
		<defaultGoal>compile</defaultGoal>
		<plugins>
			<plugin>
			<groupId>org.apache.tomcat.maven</groupId>
                        <!--使用tomcat7运行-->
			<artifactId>tomcat7-maven-plugin</artifactId>	
			<version>2.2</version>
			<configuration>
                        <!--运行端口-->
			<port>8082</port>		
                        <!--<path>/mgr</path> -->
			<uriEncoding>UTF-8</uriEncoding>
			<finalName>mgr</finalName>
                        <!--项目名-->
			<path>/KBase</path>		
			<server>tomcat7</server>	
			</configuration>
                        //如果需要发布到容器,需要下面配置
						<url>http://10.98.20.80:8080/manager/text</url>
						<username>admin</username>
						<password>admin</password>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-surefire-plugin</artifactId>
				<configuration>
					<skip>true</skip>
				</configuration>
			</plugin>
		</plugins>
	</build>
运行:tomcat7:run
发布:tomcat7:redeploy

 

tomcat8 

				<plugin>
					<groupId>org.apache.tomcat.maven</groupId>
					<artifactId>tomcat8-maven-plugin</artifactId>
					<version>3.0-r1655215</version>
					<configuration>
						<port>8080</port>
						<uriEncoding>UTF-8</uriEncoding>
						<finalName>mgr</finalName>
						<!--项目名 -->
						<path>/xxxxx</path>
						<server>tomcat</server>
                        //如果需要发布到容器,需要下面配置
						<url>http://10.98.20.80:8080/manager/text</url>
						<username>admin</username>
						<password>admin</password>
					</configuration>
				</plugin>

运行:tomcat8:run
发布:tomcat8:redeploy

发布的配置

配置tomcat的conf/tomcat-users.xml 中配置一个user


<role rolename="admin-gui"/>
<role rolename="admin-script"/>
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="123456" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/> 

tomcat8除了上一步,还需要配置webapps/manager/META-INF/context.xml,允许其他IP访问

<Context antiResourceLocking="false" privileged="true" >
  <Valve className="org.apache.catalina.valves.RemoteAddrValve" allow="^.*$" />
</Context>

 

 

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值