×

Loading...
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。
Ad by
  • 最优利率和cashback可以申请特批,好信用好收入offer更好。请点链接扫码加微信咨询,Scotiabank -- Nick Zhang 6478812600。

Eclipse "cross-reference" problem

本文发表在 rolia.net 枫下论坛I'm not sure if "cross-reference" is the right word to use here. the problem is:

I have two dummy projects built in Eclipse. In project1, there's the following class:

package ca.company.project1;

import com.institute.project2.Employee;

public class Department {
private int departmentId;
private String name;
private Employee manager;

........

}

in project2, I have the following class:

package com.institute.project2;

import ca.company.project1.Department;

public class Employee {
private int id;
private String name;
private String dob;
private String phone;
private Department department;

......

}

To make this to work, I added project1 to project2's build path, also added project2 to project1's build path. Now the classes themselves are ok, but Eclipse complaint:

"A cycle was detected in the build path of projectX. The project cannot be built until build path errors are resolved."

Can anyone please tell me what I'm doing wrong, what's the right way to do it if I wanted to keep the current project and package structure?

Thanks in advance!更多精彩文章及讨论,请光临枫下论坛 rolia.net
Report

Replies, comments and Discussions:

  • 工作学习 / 专业技术讨论 / Eclipse "cross-reference" problem
    本文发表在 rolia.net 枫下论坛I'm not sure if "cross-reference" is the right word to use here. the problem is:

    I have two dummy projects built in Eclipse. In project1, there's the following class:

    package ca.company.project1;

    import com.institute.project2.Employee;

    public class Department {
    private int departmentId;
    private String name;
    private Employee manager;

    ........

    }

    in project2, I have the following class:

    package com.institute.project2;

    import ca.company.project1.Department;

    public class Employee {
    private int id;
    private String name;
    private String dob;
    private String phone;
    private Department department;

    ......

    }

    To make this to work, I added project1 to project2's build path, also added project2 to project1's build path. Now the classes themselves are ok, but Eclipse complaint:

    "A cycle was detected in the build path of projectX. The project cannot be built until build path errors are resolved."

    Can anyone please tell me what I'm doing wrong, what's the right way to do it if I wanted to keep the current project and package structure?

    Thanks in advance!更多精彩文章及讨论,请光临枫下论坛 rolia.net
    • ide issue
      I think it's a ide issue.
      If those two classes are simple beans, try to comment out the reference and compile one class at a time. The uncomment.
      If you have very complex class(es), you could try to use ant (or command line) to compile both projects and jar it. Then remove project dependencies in eclise, just include the jar. After two projects have no errors, remove the jar and add the dependency. If it still does not work, try another ide.
    • Normally I prefer clearly defining the dependent hierarchy of packages/projects. If 2 classes from 2 packages reference each other, I put them into the same package.
    • 你两个project相互依赖,任何一个project的build依赖另一个project的class,所以你无论先build哪个,都有麻烦。eclipse搞不定了,就算eclipse能搞定,也是非常差的design。