SpringMVC啓動tomcat出現Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run異常

 

異常:Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run (default-cli) on project SpringMVC_start: Could not start Tomcat: Failed to start component [StandardServer[-1]]: Failed to start component [StandardService[Tomcat]]: Failed to start component [StandardEngine[Tomcat]]: A child container failed during start -> [Help 1]

原因:子容器在啓動期間失敗

查看pom.xml配置

依賴:

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
<!--            <scope>provided</scope>-->
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
<!--            <scope>provided</scope>-->
        </dependency>

插件:

    <build>
        <finalName>SpringMVC_start</finalName>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
            <plugins>

<!--                配置tomcat7-->
<!--                解決maven集成的tomcat6不支持jdb1.8以上版本-->
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <configuration>
                        <port>80</port>
                    </configuration>
                </plugin>
<!--                配置jdk9-->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <configuration>
                        <target>9</target>
                        <source>9</source>
                        <encoding>UTF-8</encoding>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

 

可能原因:

①servlet及jsp導致與maven集成的tomcat的servlet及jsp衝突(不過有個疑問:我嘗試沒加scope使用maven集成的tomcat啓動卻能成功,而用tomcat7啓動卻有異常)

解決方法:將代碼中的servlet及jsp的scope註釋放開即能用tomcat7啓動

 

②可能是jdk版本的關係(具體解決方式自行百度)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章