问题
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