0 Replies Latest reply on Jul 28, 2016 6:02 PM by Saria ESSID

    How springConfiguration.xml detects persistence.xml

    Saria ESSID Novice

      Hello,

       

      I created a dynamic web project with both jpa and spring, but I got this Error:

      Could not find or load main class com.journaldev.spring.jdbc.main.SpringMain

      Could you please tell me what I missed.

      Bellow are:

      Persistence.xml

      <?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">
        <persistence-unit name="HelloSpring" transaction-type="RESOURCE_LOCAL">
              <class>com.journaldev.spring.jdbc.model.Employee</class>
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <properties>
                <property name="hibernate.show_sql" value="true" />
        <property name="hibernate.hbm2ddl.auto" value="update" />
        </properties>
        </persistence-unit>
      </persistence>
      

       

      spring.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <beans xmlns="http://www.springframework.org/schema/beans"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans.xsd">
        <bean id="employeeDAO" class="com.journaldev.spring.jdbc.dao.EmployeeDAOImpl">
        <property name="dataSource" ref="dataSource" />
        </bean>
      
        <bean id="employeeDAOJDBCTemplate" class="com.journaldev.spring.jdbc.dao.EmployeeDAOJDBCTemplateImpl">
        <property name="dataSource" ref="dataSource" />
        </bean>
      
        <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/springdb" />
        <property name="username" value="root" />
        <property name="password" value="root" />
        </bean>
      
      
        <bean id="persistenceUnitManager"
         class="org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager">
        <property name="persistenceXmlLocations">
        <list>
        <value>persistence.xml</value>
        </list>
        </property>
        <property name="defaultDataSource" ref="dataSource"></property>
        </bean>
      
      
        <bean id="entityManagerFactory"
         class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
        <property name="persistenceUnitManager" ref="persistenceUnitManager"></property>
        <property name="persistenceUnitName" value="HelloSpring"></property>
        </bean>
      
      
      
      
        <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
           <property name="entityManagerFactory" ref="entityManagerFactory"></property>
        </bean>
      
      
      
      
      </beans>
      

      This is my project HelloSpring

       

      Thanks in advance