【问题标题】:The method is undefined for the type [Class Name]未定义类型 [Class Name] 的方法
【发布时间】:2015-06-12 15:16:35
【问题描述】:

我必须同时包含 pom.xml 的项目,比如说项目 A 和项目 B。在项目 B 中,我在其 pom.xml 中添加了项目 A 作为依赖项。在项目 A 中有一个类 Mirror.java,在这个类中我添加了方法,然后通过右键单击它并更新项目来更新项目 B,以便使用新代码更新项目 A 的 jar。现在,当我尝试调用此方法时,它在项目 B 中不可见,尽管 Maven 依赖项中的 .class 文件包含新方法

项目 B pom.xml

  <dependency>
        <groupId>com.intel.imc.swa.jetdb</groupId>
        <artifactId>mirror</artifactId>
        <version>0.1.4</version>
    </dependency>

Project B Test.class

 new Mirror(db.getConnectionString(), "EABase_JET4_empty.eap",eap.getAbsolutePath()).webrun();

Project A Mirror.java

   public Mirror(String source, String template, String target) throws SQLException, IOException {
    this.sourceString=source;
    this.templateFileString=template;
    this.targetFileString=target;
} 


public void webrun() {
 System.out.print("test");
}

为什么项目 B 中没有 webrun 方法?

谢谢

【问题讨论】:

    标签: java maven dependencies maven-plugin


    【解决方案1】:

    您必须先构建项目A,然后再构建项目B。您还必须在 Maven 中使用 -U 标志:

     $ mvn clean install  // in A
     $ mvn clean install -U // in B to force update of snapshots
    

    【讨论】:

    • 非常感谢我清理了项目 B 但没有清理项目 A
    猜你喜欢
    • 2014-12-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多