簡體   English   中英

在netbeans中清理並構建失敗

[英]clean and build failed in netbeans


我在Netbeans IDE 6.9中創建一個項目。在一個項目中,我有一個接口IBusinessLogic。在第二個項目中,我創建了一個實現IBusinessLogic的類BusinessLogic。在第三個項目中,我正在創建BusienssLogic的對象,並將該對象分配給IBusinessLogic的引用。 我在編寫時沒有出現任何錯誤,但是當我清理並構建第三個項目時,出現以下異常:

incompatible types
found   : com.abc.businesslogic.BusinessLogic
required: com.abc.businesslogic.interfaces.IBusinessLogic
                com.abc.businesslogic.interfaces.IBusinessLogic logic = bl;
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
D:\ProjectsFeb12\Service\nbproject\build-impl.xml:531: The following error occurred while executing this line:
D:\ProjectsFeb12\Service\nbproject\build-impl.xml:261: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 3 seconds)

據我所知,我可以在超級類型引用中分配子類型的對象,那么此異常必須是IDE的。 我該如何解決? 我也將所有代碼都移到了一個新項目中,但是沒有起作用。

碼:

package com.abc.workerhandlers;

import com.abc.businesslogic.BusinessLogic;
import com.abc.businesslogic.interfaces.IBusinessLogic;

public class MQ2MQWorker1 {

    MQ2MQWorker1(){}

    public void init(){

                BusinessLogic bl = new BusinessLogic();
                IBusinessLogic logic = bl;  // This line is giving problem
    }
}

當我運行該項目時,它可以完美執行,但是該項目的jar不在dist目錄中創建。

您確定正確的類在類路徑中嗎? 順便說一句,你不應該寫

 BusinessLogic bl = new BusinessLogic();
IBusinessLogic logic = bl;  // This line is giving problem

而是IBUsinessLogic logic = new BusinessLogic();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM