Problem Description: The error, probably is to explain the mapping mapping, can not find. hbm.xml file (Resource) a large push configuration file, debug half a day of the whole blindfolded
Finally all deleted, the whole world is quiet haha. ----------------------------then re-use the MyEclipse feature to create the automatic configuration:
New Web project, project Lib copy a database connection driver Mysql-connector-java-5.1.18-bin
Right-click on the project name to select Configure Facets Manager
will automatically generate Hibernate.cfg.xml, hibernatesessionfactory files, of course, a new package to put factory files.
The next step is to automatically generate. hbm.xml files and Entity entities classes
White space Right-click New database Connection Driver
After establishing the connection, start the connection, reverse engineer the entity class and mapping file, as shown below
The configuration file is now complete.
In addition: Useunicode=true&characterencoding=utf-8 This sentence can be added to the URL of the connection database. + This statement, solve the Chinese garbled problem.
Yes, the test class is Session.save () to insert data into the database when the error, Org.hibernate.MappingException:Unknown entity:java.lang.String
How the Entity class type is string. Look at the source, I wipe, session.save ("user"), and then decisively "" Remove, haha, everything is over.
Oh, and think of one more ... Report warning, log4j something is wrong, that is, log, and then add a log4j.properties
# Configure logging for testing:optionally with log file
Log4j.rootlogger=warn, stdout
# Log4j.rootlogger=warn, stdout, logfile
Log4j.appender.stdout=org.apache.log4j.consoleappender
Log4j.appender.stdout.layout=org.apache.log4j.patternlayout
log4j.appender.stdout.layout.conversionpattern=%d%p [%c]-%m%n
Log4j.appender.logfile=org.apache.log4j.fileappender
Log4j.appender.logfile.file=target/spring.log
Log4j.appender.logfile.layout=org.apache.log4j.patternlayout
log4j.appender.logfile.layout.conversionpattern=%d%p [%c]-%m%n
It's ready to run.