Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. class path resource [META-INF/persistence.xml] cannot be opened because it does not exist
  2.  
  3. @RunWith(SpringJUnit4ClassRunner.class)
  4. @ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/classes/applicationContext.xml",
  5. "file:src/main/webapp/WEB-INF/config/spring-security.xml"})
  6. public class KeyServiceTests {
  7.  
  8. @Test
  9. public void testKeyCreation() {
  10. ConfigurableApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
  11. KeyService keyService = (KeyService) context.getBean("keyService");
  12. // Some testing goes on here
  13. }
  14. }
  15.  
  16. <bean id="entityManagerFactory"
  17. class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  18. <property name="dataSource" ref="dataSource" />
  19. <property name="persistenceUnitName" value="hsqldb-ds" />
  20. <property name="persistenceXmlLocation" value="classpath:META-INF/persistence.xml"/>
  21. </bean>
  22.  
  23. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  24. <persistence xmlns="http://java.sun.com/xml/ns/persistence"
  25. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.0"
  26. xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
  27. <persistence-unit name="hsqldb-ds" transaction-type="RESOURCE_LOCAL">
  28.  
  29. <description>HSQLDB Persistence Unit</description>
  30. <provider>org.hibernate.ejb.HibernatePersistence</provider>
  31.  
  32. <properties>
  33. <property name="javax.persistence.jdbc.driver" value="org.hsqldb.jdbcDriver" />
  34. <property name="javax.persistence.jdbc.url" value="jdbc:hsqldb:mem:demodb" />
  35. <property name="javax.persistence.jdbc.user" value="sa" />
  36. <property name="javax.persistence.jdbc.password" value="" />
  37. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
  38. <property name="hibernate.hbm2ddl.auto" value="validate" />
  39. <property name="hibernate.show_sql" value="false" />
  40. <property name="hibernate.format_sql" value="true" />
  41. <property name="hibernate.transaction.flush_before_completion" value="true" />
  42. </properties>
  43. </persistence-unit>
  44.  
  45. @ContextConfiguration(locations = {"classpath:applicationContext.xml"})
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement