简体   繁体   中英

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

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM