我正在構建一個多模塊Maven web應用程序項目,但我在Tomcat服務器上部署WAR時遇到問題。ClassNotFound Maven War
我的項目結構是
- MyApp的
- MyAppSchemas
- MyAppUtils
- MyAppWs
這裏的問題。當我嘗試部署我的本地Tomcat服務器上生成我的戰爭,我得到以下錯誤:
Apr 19, 2017 1:42:43 PM org.apache.catalina.core.StandardContext filterStart
SEVERE: Exception starting filter ApiOriginFilter
java.lang.ClassNotFoundException: io.swagger.api.ApiOriginFilter
APIOriginFilter是MyAppSchemas模塊中產生的一類。我已經包括了MyAppSchemas罐子作爲MyAppWs POM的依賴關係:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>io.swagger</groupId>
<artifactId>MyApp</artifactId>
<version>1.0</version>
</parent>
<artifactId>MyAppWs</artifactId>
<name>MyAppWs</name>
<packaging>war</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>APP-INF/lib</classpathPrefix>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>MyAppSchemas</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>MyAppUtils</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
底線:我怎麼有我的戰爭運行時類路徑等子模塊?
我不相信它一定會有所作爲,但刪除'Maven的戰爭插件然後定義'配置。這在Tomcat中是完全無稽之談。然後在執行'mvn clean install'後,確認您的依賴jar已經放置在構建WAR文件的過程中生成的MyAppWs/target/MyAppWs/WEB-INF/lib目錄中。 –