Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. server:
  2. port: ${port:9080}
  3. spring:
  4. datasource:
  5. data: schema-setup.sql
  6. driver-class-name: org.h2.Driver
  7. # name: datasource
  8. initialize: true
  9. sql-script-encoding: UTF-8
  10. url: jdbc:h2:mem:JavaSpringBootBatch;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE;MODE=MySQL;
  11. username: sa
  12. password:
  13. # schema: schema-setup.sql
  14. profiles: # default, development, production
  15. active: default, development
  16. ---
  17. spring:
  18. h2:
  19. console:
  20. enabled: true
  21. path: /h2-console
  22. profiles: development
  23. ---
  24. server:
  25. port: ${port:80}
  26. spring:
  27. datasource:
  28. # ...datasource config here
  29. profiles: production
  30.  
  31. @Configuration
  32. public class PlayerBatchConfig {
  33. ...
  34.  
  35. @Bean
  36. public ItemWriter<Player> writer(final DataSource dataSource) {
  37. final JdbcBatchItemWriter<Player> jdbcItemWriter = new JdbcBatchItemWriter<>();
  38. ...
  39. jdbcItemWriter.setDataSource(dataSource);
  40. jdbcItemWriter.setSql(sql.toString());
  41. return jdbcItemWriter;
  42. }
  43. }
  44.  
  45. @Configuration
  46. public class PlayerBatchConfig {
  47. @Bean
  48. @ConfigurationProperties(prefix = "datasource")
  49. public DataSource dataSource() {
  50. return DataSourceBuilder.create().build();
  51. }
  52.  
  53. ...
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement