java.lang.NoSuchMethodException: org.apache.catalina.deploy.WebXml addServlet
spring boot1.4.7 基于maven,配置tomcat7.0.69遇到这个异常
原因是spring boot 1.4.7默认tomcat是tomcat8,改为tomcat7,导致版本冲突,
解决方式是:加入exclusions标签,去掉spring boot内置的tomcat
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>
上面加上
<properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <java.version>1.7</java.version> <tomcat.version>7.0.69</tomcat.version> </properties>
下面加上
<build> <finalName>hello</finalName> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.0</version> <!-- <configuration> <url>http://localhost:8080/manager/text</url> <server>tomcat7</server> <username>tomcat</username> <password>777777</password> </configuration> --> <executions> <execution> <phase>package</phase> <goals> <goal>run</goal> </goals> </execution> </executions> <!-- --> </plugin> </plugins> </build>