简体   繁体   English

Eclipse - 当maven参与时,“作为Java应用程序运行”

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

I have a maven project. 我有一个maven项目。 As activeByDefault I have the production profile. 作为activeByDefault我有生产资料。 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. 似乎我找不到使用登台配置文件在Eclipse中作为应用程序运行它的方法,除非我将activeByDefault放在登台配置文件中。 Is there a way to configure this so I don't have to edit the pom every time? 有没有办法配置这个,所以我不必每次编辑pom?

The only thing is affected in running Java app from Maven project in Eclipse is how application classpath is constructed. 从Eclipse中的Maven项目运行Java应用程序中唯一受影响的是应用程序类路径的构造方式。 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. 通常在Maven中有几个不同的类路径范围:编译,编译测试(这个实际上用于在Eclipse JDT中构造类路径)和运行时。 The runtime classpath scope is used to assemble classpath for the application launch. 运行时类路径范围用于组合应用程序启动的类路径。 The m2e is actually using Maven code to resolve it. m2e实际上是使用Maven代码来解决它。

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. 因此,您必须更改pom.xml中的配置文件激活设置,或在Eclipse项目属性/ Maven / Active Maven配置文件中指定活动配置文件。

If you want runtime profile to be different from build-time profile in Eclipse, it is not possible right now. 如果您希望运行时配置文件与Eclipse中的构建时配置文件不同,那么现在就不可能。 You'll have to submit an enhancement request for m2e to allow to specify active profiles when calculating launch classpath. 您必须提交m2e的增强请求,以允许在计算启动类路径时指定活动的配置文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Eclipse的Maven项目中编译和运行Java应用程序? - How to compile and run Java application within Maven project in Eclipse? 从Eclipse运行时,Java应用程序应在哪里创建文件? - Where should a java application create files when it is run from Eclipse? 使用Maven在Eclipse上运行一个Java包 - Run a single java package on eclipse using maven 在Eclipse的tomcat中运行Java Servlet Maven Web应用程序 - Run a java servlet maven webapp in tomcat in eclipse Java应用程序未在Eclipse Galileo中运行 - Java application not run in Eclipse Galileo 如何使用Maven和Eclipse在Java Main Application中运行JUnit测试类 - How to run JUnit Test Classes in Java Main Application using Maven and Eclipse 无法从Eclipse运行带有Maven的Java应用程序,但它可以在命令行中运行 - Can't run Java Application with Maven from Eclipse but it works in Command line 从命令行(Eclipse外)运行Java应用程序(Maven项目)时出错 - Errors when running Java Application (maven project) from command line (outside eclipse) 右键单击 Maven 项目时,Eclipse 未显示作为 Maven 测试运行 - Eclipse not showing run as maven test when right click on maven project 在 Eclipse 中运行 Java Maven 应用程序时出现 LifecycleException - LifecycleException when running Java Maven app in Eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM