Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @Controller
- @RequestMapping("/account")
- @EnableJpaRepositories
- public class AccountController {
- @Autowired
- private AccountRepository accountRepo;
- //methods
- }
- @Repository
- public interface AccountRepository extends CrudRepository<Account, Integer> {
- Account findOne(int primaryKey);
- }
- <jpa:repositories base-package="com.library.repositories"
- entity-manager-factory-ref="entityManager"></jpa:repositories>
- <tx:annotation-driven transaction-manager="transactionManager" />
- <bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
- <property name="entityManagerFactory" ref="entityManager" />
- </bean>
- <bean id="entityManager"
- class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <property name="packagesToScan" value="com.library.entities" />
- <property name="jpaVendorAdapter">
- <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
- </property>
- <property name="jpaProperties">
- <props>
- <!-- <prop key="hibernate.hbm2ddl.auto">create-drop</prop> -->
- <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
- </props>
- </property>
- </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/library" />
- <property name="username" value="root" />
- <property name="password" value="root" />
- </bean>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement