hibernate8ide在新版本中已經改名叫console了. 用如下方法運行,可以利用項目中已經建好的配置文件, 不用再配置, 減少了hibernamte8ide出錯的機會. 以前直接RUN的時候, 有各種錯誤出現. 搞得人很頭暈的.
下載最新版hibernate-extensions, 解壓到相關目錄.
在jb的工程中引入console目錄下的hibernateconsole.jar, 再引入console\lib目錄下的所有jar文件
創建一個StartHibern8IDE.java文件, 拷貝下面的代碼,然后run.
參考了一篇hibernate8ide運行在eclipse中的文章.
當然,下面的代碼,再eclipse中是一樣的用的.
用下面的代碼運行,可以解決中文問題.
import java.awt.Font;
import javax.swing.UIManager;
import com.jgoodies.clearlook.ClearLookManager;
import com.jgoodies.clearlook.ClearLookMode;
import com.jgoodies.plaf.plastic.PlasticXPLookAndFeel;
import net.sf.hibernate.cfg.Configuration;
import net.sf.hibernate.console.*;
public class StartHibern8IDE {
public static void main(String[] args) throws Exception {
Configuration configuration = new Configuration();
try {
if (System.getProperty("sun.awt.exception.handler")==null) {
System.setProperty("sun.awt.exception.handler", AWTExceptionHandler.class.getName());
} else {
System.err.println("could not install AWT handler ;(");
}
ClearLookManager.setMode(ClearLookMode.ON);
UIManager.setLookAndFeel(new PlasticXPLookAndFeel());
setUIFont (new javax.swing.plaf.FontUIResource("宋體",Font.PLAIN,12));
configuration.configure();
// run
Start.startWith(configuration);
} catch (Exception e) { // noop
e.printStackTrace();
}
}
public static void setUIFont (javax.swing.plaf.FontUIResource f){
java.util.Enumeration keys = UIManager.getDefaults().keys();
while (keys.hasMoreElements()) {
Object key = keys.nextElement();
Object value = UIManager.get (key);
if (value instanceof javax.swing.plaf.FontUIResource)
UIManager.put (key, f);
}
}
}