Eclipse - “Run as Java Application” when maven is involved

坚强是说给别人听的谎言 提交于 2019-12-13 14:27:23

问题


I have a maven project. As activeByDefault I have the production profile. It seems I can't find a way to run it as application in Eclipse using the staging profile unless I put the activeByDefault in the staging profile. Is there a way to configure this so I don't have to edit the pom every time?


回答1:


The only thing is affected in running Java app from Maven project in Eclipse is how application classpath is constructed. Generally in Maven there are several different classpaths scopes: compile, compile tests (this one is actually used to construct classpath in Eclipse JDT) and runtime. The runtime classpath scope is used to assemble classpath for the application launch. The m2e is actually using Maven code to resolve it.

So, you either have to change profile activation settings in your pom.xml or specify active profile in Eclipse project properties / Maven / Active Maven Profiles.

If you want runtime profile to be different from build-time profile in Eclipse, it is not possible right now. You'll have to submit an enhancement request for m2e to allow to specify active profiles when calculating launch classpath.



来源:https://stackoverflow.com/questions/14382522/eclipse-run-as-java-application-when-maven-is-involved

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!