默认可以不配置,执行
mvn tomcat:run
默认监听8080端口,注意。
配置插件,使用tomcat7
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>8888</port>
</configuration>
</plugin>指定了端口。
更完整的配置:
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<path>/</path> <!-- 项目访问路径 本例:localhost:9090, 如果配置的aa,则访问路径为localhost:9090/aa -->
<port>9090</port>
<uriEncoding>UTF-8</uriEncoding><!-- 非必需项 -->
</configuration>
</plugin>这个时候不能使用mvn tomcat:run了。
需要使用:
[#zeyu#]
mvn tomcat7:run
[/#zeyu#]
成功之后提示:
八月 12, 2020 10:02:35 下午 org.apache.coyote.AbstractProtocol init 信息: Initializing ProtocolHandler ["http-bio-8888"] 八月 12, 2020 10:02:35 下午 org.apache.catalina.core.StandardService startInternal 信息: Starting service Tomcat 八月 12, 2020 10:02:35 下午 org.apache.catalina.core.StandardEngine startInternal 信息: Starting Servlet Engine: Apache Tomcat/7.0.47 八月 12, 2020 10:02:38 下午 org.apache.coyote.AbstractProtocol start 信息: Starting ProtocolHandler ["http-bio-8888"]
参考:https://www.cnblogs.com/afeng2010/p/10224597.html
还刚开始学,后面路还很长。