使用maven插件Tomcat7 启动成功但是404的问题

使用maven插件Tomcat7

tomcat7-maven-plugin 插件配置

在pom.xml文件加入

    <build>
        <!-- 配置插件 -->
        <plugins>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                   <update>true</update> <!-- 热部署 -->
                    <charset>utf-8</charset> <!-- 设置字符集 -->
                    <uriEncoding>UTF-8</uriEncoding><!-- 设置uri编码 -->
                    <port>8888</port> <!-- 设置端口 -->
                    <path>/</path><!-- 设置默认访问应用的路径 -->
                    <url>http://127.0.0.1:8888/manager/text</url>
                </configuration>
            </plugin>
        </plugins>
    </build>

启动Tomcat7

使用Maven build

这里写图片描述

使用Maven 命令

在命令行中输入

mvn clean tomcat7:run

其它命令

tomcat7:run -- 启动嵌入式tomcat ,并运行当前项目
tomcat7:deploy   --部署一个web war包
tomcat7:reload   --重新加载web war包
tomcat7:start    --启动tomcat
tomcat7:stop    --停止tomcat
tomcat7:undeploy--停止一个war包

启动成功

控制台输出:

[INFO] --- tomcat7-maven-plugin:2.2:run (default-cli) @ taotao-manager-web ---
[INFO] Running war on http://localhost:8888/
[INFO] Creating Tomcat server configuration at D:\JetBrains\IdeaProjects\taotao\taotao-manager\taotao-manager-web\target\tomcat
[INFO] create webapp with contextPath: 
九月 08, 2017 8:38:08 下午 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-bio-8888"]
九月 08, 2017 8:38:08 下午 org.apache.catalina.core.StandardService startInternal
信息: Starting service Tomcat
九月 08, 2017 8:38:08 下午 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.47
九月 08, 2017 8:38:12 下午 org.apache.catalina.core.ApplicationContext log
信息: No Spring WebApplicationInitializer types detected on classpath
九月 08, 2017 8:38:12 下午 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-bio-8888"]

此时访问http://localhost:8888/ 即可

启动失败问题

需要修改依赖

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>${servlet-api.version}</version><!-- 版本自己定义 -->
    <scope>provided</scope><!-- 必须要有 -->
</dependency>

启动成功但是404

遇到404 肯定是因为路径错误
仔细检查你的默认html或者jsp等等是否与web.xml中配置的一致

<welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
</welcome-file-list>
评论 7
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值