我正在构建一个多模块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目录中。 –