tomcat7-maven-plugin啓動maven項目異常

    最近用intellij idea新建了一套maven web項目,用tomcat7-maven-plugin運行(直接運行程序,不是war包)。java

    項目集成了Spring MVC框架,對jsp頁面的處理依賴下面兩個jar包:
web

<dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>2.2.1-b03</version>
</dependency>
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>3.0-alpha-1</version>
</dependency>

   但啓動時報錯:apache

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run (default-cli) on project configuration: 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]api

    多是這兩個包跟tomcat插件中的包衝突致使的。對上面兩個依賴包添加限定後,項目能夠正常啓動。tomcat

<scope>provided</scope>

    可是當控制層返回視圖時,又出現新的錯誤:
框架

    java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Configjsp

    應該是缺乏jstl的jar包,繼續添加依賴:
maven

<dependency>
   <groupId>javax.servlet.jsp.jstl</groupId>
   <artifactId>jstl-api</artifactId>
   <version>1.2-rev-1</version>
</dependency>

    啓動時又出現以前的錯誤:ide

[ERROR] Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.2:run (default-cli) on project configuration: 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]idea

    試着運行一下war包,沒有問題,難道又是scope的問題,加上provided無效,改爲runtime也無效。難道是servlet版本(我用的是2.5)的問題嗎?

    切換servlet版本後依然報一樣的錯。

    莫非是jstl版本的問題,是否是版本高了?

    試着把1.2後面的內容去掉,一切OK!


    附上最後的依賴配置:

<dependency>
   <groupId>javax.servlet.jsp</groupId>
   <artifactId>jsp-api</artifactId>
   <version>2.2.1-b03</version>
   <scope>provided</scope>
</dependency>
<dependency>
   <groupId>javax.servlet</groupId>
   <artifactId>servlet-api</artifactId>
   <version>3.0-alpha-1</version>
   <scope>provided</scope>
</dependency>
<dependency>
   <groupId>javax.servlet.jsp.jstl</groupId>
   <artifactId>jstl-api</artifactId>
   <version>1.2</version>
</dependency>
相關文章
相關標籤/搜索