Advertisement
Guest User

Untitled

a guest
Aug 13th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. public interface ItemRepository extends CrudRepository<Item, Integer> {
  2. }
  3.  
  4. @Entity(name = "items")
  5. public class Item {
  6.  
  7. @Id
  8. @GeneratedValue(strategy = GenerationType.IDENTITY)
  9. private int id;
  10.  
  11. private String name;
  12.  
  13. private String description;
  14.  
  15. public Item() {
  16. }
  17. ...геттеры и сеттеры...
  18. }
  19.  
  20. <?xml version="1.0" encoding="UTF-8"?>
  21. <beans xmlns="http://www.springframework.org/schema/beans"
  22. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  23. xmlns:jpa="http://www.springframework.org/schema/data/jpa"
  24. xmlns:tx="http://www.springframework.org/schema/tx"
  25. xmlns:context="http://www.springframework.org/schema/context"
  26. xsi:schemaLocation="http://www.springframework.org/schema/beans
  27. http://www.springframework.org/schema/beans/spring-beans.xsd
  28. http://www.springframework.org/schema/data/jpa
  29. http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
  30. http://www.springframework.org/schema/tx
  31. http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
  32. http://www.springframework.org/schema/context
  33. http://www.springframework.org/schema/context/spring-context-3.1.xsd">
  34.  
  35. <!-- Database properties -->
  36. <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
  37. <property name="driverClassName" value="org.postgresql.Driver" />
  38. <property name="url" value="jdbc:postgresql://127.0.0.1:5432/spring_jdbc" />
  39. <property name="username" value="postgres" />
  40. <property name="password" value="1" />
  41. </bean>
  42.  
  43. <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
  44. <property name="showSql" value="true" />
  45. <property name="generateDdl" value="true" />
  46. <property name="database" value="POSTGRESQL" />
  47. </bean>
  48.  
  49. <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
  50. <property name="dataSource" value="dataSource" />
  51. <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
  52. <!-- Spring base scaling entity classes -->
  53. <property name="packagesToScan" value="ru.pravvich" />
  54. </bean>
  55.  
  56. <bean id="transactionalManager" class="org.springframework.orm.jpa.JpaTransactionManager">
  57. <property name="entityManagerFactory" ref="entityManagerFactory" />
  58. </bean>
  59.  
  60. <jpa:repositories base-package="ru.pravvich" />
  61. </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement