tomcat遇到的問以及解決方案
使用tomcat導入servlet-api座標
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<hostName>localhost</hostName> <!-- Default: localhost -->
<port>8080</port> <!-- 啓動端口 Default:8080 -->
<path>/</path> <!-- 訪問應用路徑 Default: /${project.artifactId}-->
<uriEncoding>UTF-8</uriEncoding> <!-- uri編碼 Default: ISO-8859-1 -->
</configuration>
</plugin>
- 使用插件遇到的問題
Caused by: java.lang.LinkageError: loader constraint violation: loader (instance of org/apache/catalina/loader/WebappClassLoader) previously initiated loading for a different type with name "javax/servlet/ServletContext"
- 解決方案: 也有可能是jar包衝突導致的原因
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>2.3</version>
<scope>provided</scope><!--加入該標籤-->
</dependency>