Maven Web 资源问题
我有一个 Maven Web 项目,并且在 src\main\webapp\ 文件夹下有一些 CSS 和 Javascript 文件。我经常对这些文件进行更改,并且希望快速看到我的更改。如果我运行maven install,由于项目依赖性,它需要很长时间。有时我只想更改 CSS 文件中的一行代码,而不想重新编译其他所有内容。我有一个 Maven 插件,可以将输出 war 文件发布到我的 JBoss 实例。理想情况下,我想运行一个 Maven 执行脚本,它将快速将我的 Web 资源复制到输出文件夹并重新部署更改后的 war 文件,而无需重新编译其他所有内容。
我尝试调用 generate-resources 目标,但似乎没有在 src\main\webapp 目录中查找,因为它期望我的资源位于 src\main\resources 文件夹下。我在这里缺少什么?
谢谢
I have a Maven web project and I have some CSS and Javascript files under the src\main\webapp\ folder. I constantly make changes to those files and would like to see my changes quickly. If I run maven install, it takes ages due to project dependencies. Sometimes all I want to change is one line of code in my CSS file and do not want to recompile everything else. I have a maven plugin that publishes my output war file to my JBoss instance. Ideally, I would like to run a maven execution script that will quickly copy my web resources to the output folder and reploy the changed war file without recompiling everything else.
I tried invoking the generate-resources goal but that doesn't seem to look in the src\main\webapp directory as it is expecting my resources to be under the src\main\resources folder. What am I missing here?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在生成资源插件期间添加更多要复制的资源,您可以更改构建使用的资源文件夹。
project.build.resources
属性控制在哪些文件夹中搜索资源。您可以添加:然后运行
mvn resources
来复制文件。这种方法是在任何构建的资源阶段始终复制这些文件。您可以通过使用
copy-resources
目标而不是资源来解决此问题。在这种情况下,您将使用以下配置:然后您可以运行 mvn resources:copy-resources 来复制文件。
If you want to add more resources to be copied during the generate-resources plugin, you can change the resources folders used by your build. The
project.build.resources
property controls which folders are searched for resources. You could add:You would then run
mvn resources
to copy the files.This approach is that these files will always be copied during the resources phase of any build. You can get around this by using the
copy-resources
goal instead of resources. In this case you would use the following configuration:You could then run
mvn resources:copy-resources
to copy the files.我认为您可以通过使用
war:war
目标来实现这一目标。这应该会在输出文件夹中为您生成一个 war 文件,而无需重新编译源代码。I think you could accomplish this by using the
war:war
goal. This should generate a war file in the output folder for you without re-compiling the source.