【问题标题】:Make maven add classpath entries to eclipse project使maven将类路径条目添加到eclipse项目
【发布时间】:2014-04-04 21:52:19
【问题描述】:

Maven可以通过运行“mvn eclipse:eclipse”生成eclipse项目文件

当我从 Eclipse IDE 运行某个类时,它会将类路径条目设置为

target/test-classes
target/classes
*many paths to maven artifacts used in project"

但是,我想在 .project 中编写额外的类路径条目 如何让maven做到这一点?

我使用 maven 3.1.1

【问题讨论】:

  • 到源文件夹或类文件夹或罐子?
  • 到包含配置文件的文件夹,例如 logback.xml
  • src/main/resources 将默认包含(仅用于配置文件)
  • 是的,src/main/resources 作为标准目录布局中的常规资源文件夹可以解决问题。它可能在 pom.xml 中被覆盖

标签: java maven maven-3


【解决方案1】:

pom.xml 中添加这些额外的必需条目作为依赖项,如果这些是目录,则只需编辑.classpath 文件

那就不要使用eclipse:eclipse 而是使用

<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
        <attributes>
            <attribute name="maven.pomderived" value="true"/>
        </attributes>
</classpathentry>

.classpath 并为您的目录添加条目

【讨论】:

  • 我不想只编辑 .classpath,因为在下一次 mvn eclipse:eclipse 之后这些更改将丢失。有什么方法可以将文件夹添加到 maven pom.xml 中,该文件夹将被视为类路径条目?
  • 你需要在 eclipse 中安装 m2eclipse 插件(只是说)
【解决方案2】:

有两个步骤:

  1. 将另一个文件夹作为源文件夹添加到 maven
  2. 向 maven-eclipse-plugin 添加正确的包含

有一篇关于使用 maven 为 scala 项目配置 eclipse 的文章,但这应该完全满足您的需求。您只需编辑源文件夹和包含模式:

https://www.assembla.com/spaces/scala-ide/wiki/With_Maven_CLI

** 更新**

或使用此资源的默认文件夹src/main/resources

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-11-25
    • 2017-09-18
    • 1970-01-01
    • 2010-12-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-10
    相关资源
    最近更新 更多