java - No bean named 'persistenceUnit' is defined -


im starting new proyect spring, jpa, hibernate , mysql database, having problem configuration.

i developed similar architecture, never created it, fighting this.

this dispatcher-servlet.xml

<!-- persistencia --> <bean class="org.springframework.orm.jpa.support.persistenceannotationbeanpostprocessor" />  <!-- datasource --> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource">     <property name="driverclassname" value="com.mysql.jdbc.driver" />     <property name="url" value="jdbc:mysql://localhost:3306/editor" />     <property name="username" value="root" />     <property name="password" value="root" /> </bean>  <bean id="hibernate4annotatedsessionfactory" class="org.springframework.orm.hibernate4.localsessionfactorybean">     <property name="datasource" ref="datasource" />     <property name="annotatedclasses">         <list>             <value>com.editor.entity.folderentity</value>         </list>     </property>     <property name="hibernateproperties">         <props>             <prop key="hibernate.dialect">org.hibernate.dialect.mysqldialect</prop>             <prop key="hibernate.show_sql">true</prop>         </props>     </property> </bean>  <context:annotation-config/> <context:component-scan base-package="com.editor" /> 

this main dao persistence config.

@persistencecontext(unitname = "persistenceunit") private entitymanager entitymanager; 

i have running mysql database running in machine. have persistence.xml file in machine.

meta-inf/persistence.xml <?xml version="1.0" encoding="utf-8"?> <persistence version="2.0" 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_2_0.xsd">     <persistence-unit name="persistenceunit" transaction-type="jta">         <provider>org.hibernate.ejb.hibernatepersistence</provider>         <class>com.gamecreator.editor.entity.folderentity</class>         <properties>             <property name="javax.persistence.jdbc.url" value="jdbc:mysql://localhost:3306/gamecreator"/>             <property name="javax.persistence.jdbc.user" value="root"/>             <property name="javax.persistence.jdbc.password" value="root"/>             <property name="javax.persistence.jdbc.driver" value="com.mysql.jdbc.driver"/>         </properties>     </persistence-unit> </persistence> 

i have spring , persistence configuration, , tag persistenceunit in dao, not working. dont know if "connected" in correct way elements.

i read lot topic, can't make working. help? each tutorial topic different.

if comment persistence.xml file, same error, think file isn't loaded.

your annotation wrong. should be

@persistencecontext(unitname = "gamecreatordatabase") private entitymanager entitymanager; 

Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -