Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface ItemRepository extends CrudRepository<Item, Integer> {
- }
- @Entity(name = "items")
- public class Item {
- @Id
- @GeneratedValue(strategy = GenerationType.IDENTITY)
- private int id;
- private String name;
- private String description;
- public Item() {
- }
- ...геттеры и сеттеры...
- }
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:jpa="http://www.springframework.org/schema/data/jpa"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:context="http://www.springframework.org/schema/context"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/data/jpa
- http://www.springframework.org/schema/data/jpa/spring-jpa-1.0.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context-3.1.xsd">
- <!-- Database properties -->
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
- <property name="driverClassName" value="org.postgresql.Driver" />
- <property name="url" value="jdbc:postgresql://127.0.0.1:5432/spring_jdbc" />
- <property name="username" value="postgres" />
- <property name="password" value="1" />
- </bean>
- <bean id="jpaVendorAdapter" class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
- <property name="showSql" value="true" />
- <property name="generateDdl" value="true" />
- <property name="database" value="POSTGRESQL" />
- </bean>
- <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" value="dataSource" />
- <property name="jpaVendorAdapter" ref="jpaVendorAdapter" />
- <!-- Spring base scaling entity classes -->
- <property name="packagesToScan" value="ru.pravvich" />
- </bean>
- <bean id="transactionalManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManagerFactory" />
- </bean>
- <jpa:repositories base-package="ru.pravvich" />
- </beans>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement