Eclipse - “以Java应用程序运行”当涉及到maven时 [英] Eclipse - "Run as Java Application" when maven is involved

查看:194
本文介绍了Eclipse - “以Java应用程序运行”当涉及到maven时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个maven项目。作为 activeByDefault 我有生产配置文件。看来我找不到一种方法来运行它作为应用程序在Eclipse使用分段配置文件,除非我把 activeByDefault 在暂存配置文件中。
有没有办法配置,所以我不需要每次编辑pom?

解决方案

在Eclipse中运行Java应用程序的唯一的事情就是如何构建应用程序类路径。通常在Maven中有几个不同的类路径范围:编译,编译测试(这个实际上用于构建Eclipse JDT中的类路径)和运行时。运行时类路径范围用于组合应用程序启动的类路径。 m2e实际上是使用Maven代码解决它的。



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



如果希望运行时配置文件与Eclipse中的生成时间配置文件不同,现在是不可能的。您必须提交m2e的增强请求,以便在计算启动类路径时指定活动的配置文件。


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.

这篇关于Eclipse - “以Java应用程序运行”当涉及到maven时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆