使用 IntelliJ 在 webapp 运行配置中使用 Maven 覆盖?
我正在开发一个基于木兰的网站。我正在使用 webapp 原型来创建一个新的 Web 应用程序。使用命令行,我可以生成 WAR 并将其部署到我的容器 (Tomcat) 中。然后我运行它并且工作正常。
我的下一步是将我的项目结构导入 IntelliJ。 IntelliJ 认为一切都很好,并且能够全部编译。我已经通过首先执行 Maven clean 进行了测试,然后让 IntelliJ 完成其余的工作(重建项目)。
最后一步是让它在我的容器中运行。我之前已经为网络应用程序设置了运行配置(它们不使用战争覆盖),并且它们工作得很好。在本例中,我像以前一样进行设置,并指向我的分解的 Web 应用程序工件。
一旦我运行 tomcat,它就找不到我的 web 应用程序。我发现覆盖层尚未合并到项目的目标目录中(通常是在执行 maven install 时的情况)。然而,IntellJ 在我的项目中创建了一个覆盖目录,并在其中解压了(覆盖/超级)WAR 文件。
当我自己安装 Maven,然后在 IntelliJ 中运行 Tomcat 时,它就可以工作了。这是显而易见的,因为所有需要的文件现在都在我的目标目录中(例如 web.xml :))。
我想要的是这样的: - IntelliJ 知道,当它运行 Tomcat 时,它应该像“mvn install”或“mvn package”一样准备好目标目录。
它的作用: - 它的作用介于两者之间。它确实创建了一个目标目录,并且确实从 webapp 项目复制资源。它不覆盖任何 WAR 依赖项,因此 webapp 目标目录不完整。
有人有解决这个问题的建议吗?
I am developing a magnolia based website. I am using the webapp archetype to create a new web application. Using the command line I am able to produce a WAR and deploy that in my container (Tomcat). I then run it and it works fine.
My next step was to import my project structure into IntelliJ. IntelliJ sees everything fine, and is able to compile it all. I have tested this by doing a maven clean first, and then let IntelliJ do the rest (rebuild project).
The last step is to let it run in my container. I have set up the run configurations before for web apps (they do not use war overlays), and they worked just fine. In this case I set it up just like before and point to my exploded webapp artifact.
Once I run tomcat, it does not find my webapp. I find that the overlay has not been merged into the target directory of the project (which normally is the case when just doing maven install). IntellJ however has created an overlays directory in my project and unpacked the (overlay/super) WAR file in there.
I get it working when I do a maven install myself, and then run Tomcat in IntelliJ. Which is obvious, because all sorts of needed files are now in my target directory (like a web.xml for example :)).
What I want is this:
- IntelliJ knows that when it runs Tomcat, it should have prepared the target directory just like "mvn install" or "mvn package" would do.
What it does:
- It does something in between. It does create a target dir, and it does copy resources from the webapp project. It does not overlay any WAR dependency, hence the webapp target dir is incomplete.
Anyone has any tips to solve this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现在运行配置中选中“run maven goal”复选框并设置 mvn package 确实可以使其工作。
I found that checking the "run maven goal" checkbox in the run configuration, and setting mvn package does make it work.