我有一个旧的 struts 1 应用程序,它一直是使用 Ant 构建的,我正在将其转换为使用 Maven。我的应用程序的结构是模块化的,包含模块中的依赖项管理。包含模块的 dep mgmt 部分包含:
<dependencyManagement>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jsp-api</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
...
</dependencies>
</dependencyManagement>
当我构建战争(我package
从包含模块运行 Maven 作业)并使用来自 intelliJ 的战争运行 Tomcat 配置时,我在浏览器中看到以下内容:
org.apache.jasper.JasperException: org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:161)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
org.apache.jasper.JasperException: Unable to load class for JSP
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:630)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:149)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
root cause
java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
java.net.URLClassLoader$1.run(URLClassLoader.java:202)
java.security.AccessController.doPrivileged(Native Method)
java.net.URLClassLoader.findClass(URLClassLoader.java:190)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:134)
org.apache.jasper.servlet.JasperLoader.loadClass(JasperLoader.java:66)
org.apache.jasper.JspCompilationContext.load(JspCompilationContext.java:628)
org.apache.jasper.servlet.JspServletWrapper.getServlet(JspServletWrapper.java:149)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:340)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
我可以通过搜索找到的所有内容都表明原因是 javax.servlet jar 中的版本冲突,但我的 WEB-INF/lib 目录中根本没有任何内容。我尝试过使用, 和 even的范围provided
,但这些都没有任何帮助。compile
install/pom
tomcat 日志中没有任何其他内容。
我确认jsps正在编译。我正在使用 jspc-maven-plugin。
在我的子模块(不是包含的)pom.xml 中,我有:
<build>
<!-- default goal to run if somebody doesn't pick one (rarely matters) -->
<defaultGoal>install</defaultGoal>
<!-- resources and filtering - also see configuration under maven-war-plugin below -->
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>src/main/resources/${env}.properties</filter>
<filter>src/main/resources/${env}.tokens</filter>
</filters>
<plugins>
<!-- begin - precompiling jsps -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jspc-maven-plugin</artifactId>
<executions>
<execution>
<id>jspc</id>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<warSourceDirectory>${basedir}/src/main/webroot</warSourceDirectory>
<inputWebXml>${basedir}/src/main/webroot/WEB-INF/web.xml</inputWebXml>
<!--<workingDirectory>${basedir}/src/main/webroot</workingDirectory>-->
</configuration>
</execution>
</executions>
</plugin>
<!-- end - precompiling jsps -->
<!-- used to build warfiles -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.0</version>
<configuration>
<webResources>
<resource>
<directory>${pom.basedir}/src/main/webroot</directory>
<filtering>true</filtering>
<!--<targetPath>WEB-INF</targetPath>-->
</resource>
</webResources>
</configuration>
</plugin>
</plugins>
</build>
我可以在 Maven 构建输出中看到正在编译 jsps。但我仍然得到 JasperException。