在Intellij失败中的Maven构建应用程序的第一次运行
我有一个我想与Maven一起构建的项目,但使用Intellij进行运行,即不委派Maven的委托行动。我有一个应用程序运行配置,该配置指向我的项目的主要类别,并在1的启动前动作。运行Maven目标'项目名称:编译器:编译'
。我第一次只运行此配置,我得到:
错误:找不到或加载主类xx.main
引起的:java.lang.classnotfoundexception:xx.main
和后续(使用完全相同的运行config)运行,它可以很好地工作。
注意:如果我为项目有一个单独的Maven构建目标,然后先运行该应用程序,然后运行应用程序目标(在启动前无需构建),则首先可以使用。我还尝试在启动动作之前设置一个构建目标,结果与失败相同。仅当我尝试以同一目标构建和运行时,才会发生这种情况。
似乎Intellij在运行任何事物之前都在缓存构建状态,然后在Maven构建运行后使用相同的状态...有人知道为什么会发生这种情况,并且是否有修复它的方法,还是我只是卡住了运行它每次清洁后两次?如果需要,很高兴提供更多细节。
背景是为什么我想做一个步骤:我将其设置为一些初级(非常容易弄乱事物)开发人员,而越少的步骤越好。我不希望他们考虑如何使它运行。
I have a project that I want to build with Maven but run with IntelliJ, i.e. not delegate run actions to Maven. I have an Application Run Configuration that points at the main class of my project, with a Before Launch action of 1. Run Maven Goal 'Project Name: compiler:compile'
. The FIRST time only that I run this config, I get:
Error: Could not find or load main class xx.Main
Caused by: java.lang.ClassNotFoundException: xx.Main
And on subsequent (using the exact same run config) runs, it works perfectly.
Note: if I have a separate Maven Build Target for my project and I run that first and then the Application Run Target (without the build before launch), it works first try. I've also tried setting a Before Launch action to run that Build Target, with the same failure as a result. This ONLY occurs when I try to build and run in the same target.
It seems like IntelliJ is caching the build state BEFORE anything runs and then using that same state AFTER the Maven Build has run... Does anyone know why this occurs and if there is a way to fix it, or am I just stuck running it twice after every clean? Happy to provide more detail if required.
Background as to why I want to do it one step: I'm setting this up for some very junior (and VERY prone to messing things up) devs and the fewer steps there are, the better. I don't want them to have to think about how to make it run.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如TGDavies在评论中所建议的那样,可以通过在之前的启动步骤中添加MAVEN构建任务后第一次进行此工作。我的主要运行目标现在在启动之前:
1。运行Maven目标'项目名称:编译器:编译'
2。构建
。显然,该解决方案并不理想,但是在此阶段,我会发挥作用。我将与Intellij一起筹集一张票,希望它将得到解决...谢谢Tgdavies!As suggested by tgdavies in a comment, it's possible to make this work first time by adding an IntelliJ Build task following the Maven Build task in the Before launch steps. My Main Run Target now has Before launch:
1. Run Maven Goal 'Project Name: compiler:compile'
2. Build
. Obviously this solution is less than ideal but at this stage, I'll take functional. I'll be raising a ticket with IntelliJ and hopefully it will be addressed... Thanks tgdavies!