我創建了一個沒有任何實作的介面
@Service
public interface MyInterface{
default void doSomething{
System.out.print("print something");
}
}
@Autowired 可以注釋 MyInterface 嗎?
@Autowired
MyInterface myInterFace;
uj5u.com熱心網友回復:
不,你不能,因為 Spring 試圖實體化它來創建一個 Bean (@Service),但它是一個介面,所以這是不可能的。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/446009.html
