当前位置:Gxlcms > 数据库问题 > spring-boot-oracle spring-batch

spring-boot-oracle spring-batch

时间:2021-07-01 10:21:17 帮助过:23人阅读

* Nothing special here a simple JpaItemWriter * @return */ @Bean public ItemWriter<Person> writer() { JpaItemWriter writer = new JpaItemWriter<Person>(); writer.setEntityManagerFactory(entityManagerFactory().getObject()); return writer; }

 

    /**
     * As data source we use an external database
     *
     * @return
     */

    @Bean
    public DataSource dataSource() {
        DriverManagerDataSource dataSource = new DriverManagerDataSource();
        dataSource.setDriverClassName(databaseDriver);
        dataSource.setUrl(databaseUrl);
        dataSource.setUsername(databaseUsername);
        dataSource.setPassword(databasePassword);
        return dataSource;
    }


    @Bean
    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {

        LocalContainerEntityManagerFactoryBean lef = new LocalContainerEntityManagerFactoryBean();
        lef.setPackagesToScan("com.iqmsoft.spring.batch");
        lef.setDataSource(dataSource());
        lef.setJpaVendorAdapter(jpaVendorAdapter());
        lef.setJpaProperties(new Properties());
        return lef;
    }


    @Bean
    public JpaVendorAdapter jpaVendorAdapter() {
        HibernateJpaVendorAdapter jpaVendorAdapter = new HibernateJpaVendorAdapter();
        jpaVendorAdapter.setDatabase(Database.POSTGRESQL);
        jpaVendorAdapter.setGenerateDdl(true);
        jpaVendorAdapter.setShowSql(false);

        jpaVendorAdapter.setDatabasePlatform("org.hibernate.dialect.PostgreSQLDialect");
        return jpaVendorAdapter;
    }

 



 https://github.com/Murugar/SpringBootBatchJPA

 

spring-boot-oracle spring-batch

标签:ble   copy from   boot   org   write   password   pack   art   ring   

人气教程排行