Guest User

Untitled

a guest
May 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1. org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'Foo' available
  2.  
  3. @Component
  4. public class UnitOfWork {
  5. @PersistenceContext(unitName="Foo")
  6. private EntityManager entityManager;
  7. }
  8.  
  9. @Configuration
  10. @ComponentScan("com.foo.package")
  11. public class Config {
  12. }
  13.  
  14. <?xml version="1.0" encoding="UTF-8"?>
  15. <persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
  16. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17. xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
  18. http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
  19. version="2.1">
  20.  
  21.  
  22. <persistence-unit name="Foo">
  23. <provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
  24. <properties>
  25. <property name="javax.persistence.jdbc.driver" value="com.mysql.cj.jdbc.Driver" />
  26. <property name="hibernate.dialect" value="org.hibernate.dialect.MySQL57Dialect"/>
  27. <property name="hibernate.archive.autodetection" value="class" />
  28. <property name="hibernate.show_sql" value="true" />
  29. <property name="hibernate.format_sql" value="true" />
  30. <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/foo?useSSL=false" />
  31. <property name="hibernate.connection.username" value="foo"/>
  32. <property name="hibernate.connection.password" value="foo" />
  33. </properties>
  34. </persistence-unit>
  35. </persistence>
  36.  
  37. <dependency>
  38. <groupId>org.springframework</groupId>
  39. <artifactId>spring-core</artifactId>
  40. <version>${org-springframework.version}</version>
  41. </dependency>
  42.  
  43. <dependency>
  44. <groupId>org.springframework</groupId>
  45. <artifactId>spring-context</artifactId>
  46. <version>${org-springframework.version}</version>
  47. </dependency>
  48.  
  49. <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-jpa -->
  50. <dependency>
  51. <groupId>org.springframework.data</groupId>
  52. <artifactId>spring-data-jpa</artifactId>
  53. <version>2.0.7.RELEASE</version>
  54. </dependency>
  55. <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
  56. <dependency>
  57. <groupId>org.springframework</groupId>
  58. <artifactId>spring-orm</artifactId>
  59. <version>5.0.6.RELEASE</version>
  60. </dependency>
Add Comment
Please, Sign In to add comment