Getting Started --- hibernate configuration [the next day]

This article first said that knowledge, and the premise of a configuration step must be configured. Besides subsequent configuration problems, and finally examples. Reference can be one, two, four, configure learning.

If a problem occurs, then refer to three

A, hibernate understanding:

Fully automated, database manipulation, configuration should pay attention to, and class header information, please see if ctrl + mouse click to jump spelling errors [] is correct, please note that some of the spelling characters.

Second, note that the configuration at the time of writing the configuration file:

First of all:

And built at the same level resource src folder --- "New hibernate.cfg.xml file to write the contents of the front:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

Second: ctrl + mouse click to download the file to a directory:

http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd

At last:

In eclipse, window-> preference, and then proceed as follows:

 

 

 Having then :( Add, so the show is that I re-edited screenshot, the first line, download the file path, key to select URL, key to write the correct URL address)

 

Third, pay attention: Follow-up finish writing program code problems arise:

Finally finding is that class which hibernate.cfg.xml read the wrong path and xml file relational mapping Customer.hbm.xml.

Corrections are:

 

After running appear:

对于出现的[INFO] Environment - -hibernate.properties not found可以先不管,查阅资料说的是没有日志配置的情况下时非必须的。

现在解决后面的报错问题:

 

四、完整的配置文件及示例:

 

五:总结:

配置文件需要写正确,路径需要注意,以及读取配置文件的Factory要正确。

 

Guess you like

Origin www.cnblogs.com/ciscolee/p/10942389.html