Maven,jsp文件依赖 [英] maven, jsp files in dependency
问题描述
我正在使用maven2进行依赖项管理.我有一个项目,其中包含一些Java文件和一些jsp文件,以及另一个项目(一个Web项目),该项目取决于第一个项目.如何从Web项目访问jsp文件?
I'm using maven2 for dependency management. I have one project that contains some Java files and some jsp files and another project, a web project, that depends on the first project. How do I access the jsp files from the web project?
我可以看到jsp文件被添加到1-0-SNAPSHOT-sources.jar
而不是1-0-SNAPSHOT.jar
(作为依赖项添加到Web项目pom.xml中).
I can see that the jsp files are added to 1-0-SNAPSHOT-sources.jar
and not 1-0-SNAPSHOT.jar
(which is added as a dependency in the web projects pom.xml).
推荐答案
我认为正确的Maven方法是将JSP文件放在您的Web项目中的/src/main/webapp下.如果由于某种原因无法做到这一点,则可以使用 Maven依赖插件将所需的文件复制到您的webapp中.或者,如果您仍然有一个WAR项目,则可以使用叠加复制JSP文件.第二个选项(我推荐)看起来像这样:
I think the correct Maven-way to do it would be to put the JSP files in your web project under /src/main/webapp. If that for some reason is not possible, you could use the Maven Dependency Plugin to copy the needed files into your webapp. Or, if you have a WAR project anyway, you could use an Overlay to copy the JSP-Files. The second option (which I'd recommend), would look something like this:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<overlays>
<overlay>
<groupId>myGroupId</groupId>
<artifactId>myArtifactId</artifactId>
<type>jar</type>
<includes>
<include>**/*.jsp</include>
</includes>
<targetPath>WEB-INF/pages</targetPath>
</overlay>
</overlays>
</configuration>
</plugin>
</plugins>
</build>
这篇关于Maven,jsp文件依赖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!