Geeks, please accept the hero post of 2021 Microsoft x Intel hacking contest>>>
A few days ago, I learned to build an e-commerce website, Baba sports net, with Mr. Li Huoming of Chuanzhi blog( http://www.babasport.com/ ), the teacher explained it in great detail. This is also a shopping website mainly developed by him. You can imagine how much energy the teacher has expended. Although he has not been able to make a profit for the time being, I don’t think it’s a big deal, Teachers can selflessly share the source code to us, and there are supporting videos( http://www.itcast.cn/itcast_ static/babaSport_ The whole software development process of the project is clearly shown to J2EE lovers for learning. Thank you, Mr. Li Huoming
In the initial stage, to build the JPA development environment is to add all the jar files to the user library in turn
At the same time, a new meta-inf folder is created under the classpath of the web project
And create a new persistence. XML under this folder
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0">
<persistence-unit name="itcast" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQL5Dialect" />
<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.username" value="root" />
<property name="hibernate.connection.password" value="123456" />
<property name="hibernate.connection.url" value="jdbc.mysql://localhost:3306/itcast?useUnicode=true&characterEncoding=UTF-8" />
<property name="hibernate.max_fetch_depth" value="3" />
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.jdbc.fetch_size" value="18" />
<property name="hibernate.jdbc.batch_size" value="10" />
<property name="hibernate.format_sql" value="true" />
</properties>
</persistence-unit>
</persistence>
Then unit test is used to test whether the JPA platform is built successfully, and the following exception is reported
log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
log4j:WARN Please initialize the log4j system properly.
Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named itcast
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:89)
at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:60)
at junit.test.Test.main(Test.java:13)
As a result, the man who was worried and didn’t get any answers on many websites. For several days, he didn’t make any progress until he once saw a brother in soso asking, but he solved the problem himself. I had to say that he was a bully. I almost gave up. He replied: “the hibernate version is different, the DTD statement of the configuration file is different
With “I have a glimmer of hope again. I think of the JPA environment building video in the spring 2.5 tutorial video that Mr. Li Huoming once opened. After watching a little, I downloaded it at the same time
After decompressing, select several core files and remove the exception
I’m finally relieved, “hibernate version is different, DTD declaration of configuration file is different
“With” this explanation I also have to the same kind, before thought that the card here can not solve it, thank you very much for the brother’s reminder
Similar Posts:
- How to Solve Java.sql.sqlexception: ora-02289: sequence does not exist
- [Solved] spark Connect hive Error: javax.jdo.JDODataStoreException: Required table missing : “`DBS`” in Catalog “” Schema “”
- Failed to obtain JDBC Connection
- [Solved] Java:Hibernate Error executing DDL via JDBC Statement
- :org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
- [Solved] Springboot Project Connect MYSQL Error: Establishing SSL connection without server’s identity verification is not recommended.
- Solve the error of springboot failed to load ApplicationContext
- [Solved] org.hibernate.MappingException: Unknown entity
- [Solved] Ambari Start Error: The server time zone value ‘EDT’ is unrecognized or represents more than one time zone
- [Solved] Caused by: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure