我正在构建一个模块化的 Web 应用程序,其中有一些 Spring 组件打包在 jar 依赖项(不同的模块)中。该 jar 还包含一些 JSP 资源,例如:
- Module + src/main/resources/META-INF/resources/module/*.jsp
Now I want to override a specific JSP using the following structure in my application.
- App + src/main/resources/META-INF/resources/module/menu.jsp
When running the application using tomcat7:run
it will sometimes show the overridden menu.jsp
but will any subsequent runs will end up with the old one.
Running with tomcat7:run-war
was more promising. Most of the runs the new menu.jsp is shown. But when deploying the application to another Tomcat 7 instance the old menu is visible once again.
The menu.jsp is include using pageContext.include("/module/menu.jsp");
which is called by a custom tag.
How can I make this overriding of resources more reliable? I'm totally clueless since it seems to be randomly working. I hope somebody can shed some light here.
Not sure if this is relevant but to be able to use component scanning I need to unpack the jar classes with the following plugin configuration.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>process-resources</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<overWriteIfNewer>false</overWriteIfNewer>
<artifactItems>
<artifactItem>
<groupId>my.company</groupId>
<artifactId>my-dependency</artifactId>
<version>1.0-SNAPSHOT</version>
<type>jar</type>
<outputDirectory>${project.build.directory}/classes</outputDirectory>
<includes>**/*.class</includes>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
最佳答案
经过一番折腾后,我意识到我犯了一个非常简单的错误。我现在搬家了
- App + src/main/resources/META-INF/resources/module/menu.jsp
到达地点
- App + src/main/webapp/module/menu.jsp
一切都按预期进行。
关于jsp - 覆盖 jar META-INF/resources 中的 JSP 文件不可预测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24220328/