Created
April 5, 2020 17:48
-
-
Save lexblay/ecf646bd1c703f838028585ccfa7d3c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.was; | |
import javax.sql.DataSource; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.context.annotation.Bean; | |
import org.springframework.context.annotation.Configuration; | |
import org.springframework.context.annotation.Primary; | |
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean; | |
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter; | |
import org.springframework.transaction.annotation.EnableTransactionManagement; | |
@Configuration | |
@EnableTransactionManagement | |
public class ConfigJpa { | |
@Autowired | |
private DataSource dataSource; | |
@Primary | |
@Bean | |
public LocalContainerEntityManagerFactoryBean entityManagerFactory() { | |
LocalContainerEntityManagerFactoryBean emfBean = new LocalContainerEntityManagerFactoryBean(); | |
emfBean.setPackagesToScan("com.*"); | |
emfBean.setPersistenceUnitName("persistenceWas"); | |
emfBean.setJpaVendorAdapter(new HibernateJpaVendorAdapter()); | |
emfBean.setDataSource(dataSource); | |
return emfBean; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment