java 为什么 maven 不在我的 jar 中包含 JSP 文件?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15674366/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why doesn't maven include the JSP files in my jar?
提问by klactose
I have an embedded jetty (version 8.1.8) web app I am packaging as a jar and which uses JSP for its frontend. It is built with maven version 3.0.3. The problem is that when I do: mvn package
it is including everything except my *.jsp files. I've tried to relocate them many different places but no luck.
我有一个嵌入式 jetty(8.1.8 版)Web 应用程序,我将其打包为 jar 并使用 JSP 作为其前端。它是用 maven 3.0.3 版构建的。问题是,当我这样做时:mvn package
它包括除 *.jsp 文件之外的所有内容。我曾尝试将它们搬迁到许多不同的地方,但没有成功。
I've tried to add <include>src/main/java/**/*.jsp</include>
to the maven-compiler-plugin
section of my pom. But that had no effect either.
我试图添加<include>src/main/java/**/*.jsp</include>
到maven-compiler-plugin
我的 pom.xml 部分。但这也没有效果。
Is there a way to be certain that jsp files get included?
有没有办法确定包含 jsp 文件?
回答by klactose
My solution was to add the jsp files to src/main/webapp and to add the following snippet in the pom file:
我的解决方案是将 jsp 文件添加到 src/main/webapp 并在 pom 文件中添加以下代码段:
<build>
<resources>
...
<resource>
<directory>src/main/webapp</directory>
</resource>
...
</resources>
...
</build>
回答by Evgeniy Dorofeev
Try to place .jsp into src/main/resources, Maven ignores all but .java files in src/main/java
尝试将 .jsp 放入 src/main/resources,Maven 忽略 src/main/java 中除 .java 之外的所有文件