1
由於buildSessionFactory方法在休眠3已經過時,我們必須通過ServiceRegistry創建會話工廠。我已經創造了它下面喜歡,初始化ServiceRegistry休眠4
Configuration configuration = new Configuration().configure();
Map<String, String> map = new HashMap<String, String>((Map)configuration
.getProperties());
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(map)
.buildServiceRegistry();
但它顯示我像下面的PMD錯誤,
Multiple markers at this line
- Type safety: The expression of type Map needs unchecked conversion to conform to Map<? extends String,? extends
String>
- Map is a raw type. References to generic type Map<K,V> should be parameterized
我應該如何避免呢?這是因爲在(Map)configuration.getProperties()中投了對嗎?
爲什麼不能我使用泛型那裏像,
3210而且上面是初始化服務註冊表的正確方法正確的,因爲()方法接受一個Map作爲參數applySettings?
的(地圖)給我編譯錯誤,無法從屬性轉換爲Map 和Map ,?>給我編譯錯誤構造函數HashMap (Map )未定義 –
FrankD