maven中配置tomcat插件:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <!-- tomcat7的插件, 不同tomcat版本这个也不一样 --> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <!-- 通过maven tomcat7:run运行项目时,访问项目的端口号 --> <port>80</port> <!-- 项目访问路径 本例:localhost:9090, 如果配置的aa, 则访问路径为localhost:9090/aa--> <path>/</path> </configuration> </plugin>
错误:
Failed to execute goal org.apache.tomcat.maven:tomcat7-maven-plugin:2.1:run (default-cli) on project SSM_demo01: 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配置文件中加入servlet-api坐标,但是没加`<scope>provided</scope>`这个属性,所以报错,后来直接导入一整块坐标,没把之前的删除,导致jar包冲突,也会提示上边这个错误
解决:在pom.xml文件中只导入下边那一块坐标就行了,注意作用域
<dependency> <groupId>javax.servlet</groupId> <artifactId>servlet-api</artifactId> <version>2.5</version> </dependency>
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <version>3.1.0</version> <scope>provided</scope>/*之前缺少这一行*/ </dependency>
jar包不能冲突,不然也会报错