SEC-2321: Improve Java Config defaults for JavaScript clients
This commit is contained in:
@@ -4,9 +4,12 @@ import javax.sql.DataSource;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.DependsOn;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
|
||||
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
|
||||
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.Database;
|
||||
@@ -39,6 +42,15 @@ public class DataConfiguration {
|
||||
return factory;
|
||||
}
|
||||
|
||||
@Bean
|
||||
@DependsOn("entityManagerFactory")
|
||||
public ResourceDatabasePopulator initDatabase(DataSource dataSource) throws Exception {
|
||||
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
|
||||
populator.addScript(new ClassPathResource("data.sql"));
|
||||
populator.populate(dataSource.getConnection());
|
||||
return populator;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PlatformTransactionManager transactionManager() {
|
||||
JpaTransactionManager txManager = new JpaTransactionManager();
|
||||
|
||||
Reference in New Issue
Block a user