Re: [KSUG] Spring Boot(JPA) + Batch, JOB ํ˜ธ์ถœ์‹œ "BATCH_JOB_INSTANCE" ํ…Œ์ด๋ธ”์„ ์ฐพ์ง€ ๋ชปํ•˜๋Š” ํ˜„์ƒ

710 views
Skip to first unread message

์„œ์ง„์ฒ 

unread,
Jun 7, 2017, 5:52:41โ€ฏAM6/7/17
to ks...@googlegroups.com
ํ˜น์‹œ ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ํ•˜๊ฒŒ ์„ค์ •๋˜์–ด์žˆ์œผ์‹ ๊ฐ€์š”?

2017. 6. 7. ์˜คํ›„ 6:40์— "์˜ค์Šนํ˜„" <wonz...@gmail.com>๋‹˜์ด ์ž‘์„ฑ:
Spring Batch ํ•™์Šต๊ฒธ ์ƒ˜ํ”Œ์„ ๋งŒ๋“ค์–ด๋ณด๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค.

์˜๋„๋Š” ์Šคํ”„๋ง ์Šค์ผ€์ค„๋Ÿฌ ๋˜๋Š” ์™ธ๋ถ€ ํ˜ธ์ถœ์— ์˜ํ•ด ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌํ˜„ํ•ด๋ณด๋ ค ํ•ฉ๋‹ˆ๋‹ค.
์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ตฌ๋™์‹œ ์ž๋™์œผ๋กœ JOB์ด ์‹คํ–‰๋˜๋„๋กํ•˜๋Š” spring.batch.job.enabled ์†์„ฑ์ด true ์ผ๋•Œ๋Š” ๊ตฌ๋™์‹œ ์ •์ƒ์ ์œผ๋กœ ๋™์ž‘ํ•˜๊ณ  ์žˆ๋Š”๋ฐ,
spring.batch.job.enabled ๊ฐ’์„ false ๋กœ ๋ณ€๊ฒฝํ•˜๊ณ  JobLauncher๋ฅผ ์ด์šฉํ•ด ์ง์ ‘ JOB์„ ์‹คํ–‰ํ•˜๋ คํ•˜๋ฉด ์•„๋ž˜์™€ ๊ฐ™์ด ์—๋Ÿฌ๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.

์„ค์ •ํŒŒ์ผ:
spring:
ย  jpa:
ย  ย  generate-ddl: true
ย  ย  hibernate:
ย  ย  ย  ddl-auto: create-drop
ย  ย  dialect: org.hibernate.dialect.H2Dialect
ย  datasource:
ย  ย  url: jdbc:h2:mem:b;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE
ย  ย  username: sa
ย  ย  password:
ย  ย  driverClassName: org.h2.Driver
ย  ย  initialize: true
ย  h2:
ย  ย  console:
ย  ย  ย  enabled: true
ย  ย  ย  path: ย /h2
ย  batch:
ย  ย  job:
ย  ย  ย  enabled: false

Java Code :

@Component
@Slf4j
public class TestComponent{


ย  ย  @Autowired
ย  ย  JobLauncher jobLauncher;

ย  ย  @Autowired
ย  ย  ExBatch exBatch;

ย  ย  @PostConstruct
ย  ย  public void init(){
try{
ย  ย  ย  ย  ย  ย  jobLauncher.run(exBatch.job(), new JobParameters());

ย  ย  ย  ย  }catch (Exception e){
ย  ย  ย  ย  ย  ย  log.error(e.getMessage());
ย  ย  ย  ย  }
ย  ย  }


}



๋กœ๊ทธ :ย 
2017-06-07 18:26:48.730 ย INFO 21868 --- [ ย  ย  ย  ย  ย  main] o.s.jdbc.support.SQLErrorCodesFactory ย  ย : SQLErrorCodes loaded: [DB2, Derby, H2, HSQL, Informix, MS-SQL, MySQL, Oracle, PostgreSQL, Sybase, Hana]
2017-06-07 18:26:48.734 ERROR 21868 --- [ ย  ย  ย  ย  ย  main] com.wonzopein.service.DefaultService ย  ย  : PreparedStatementCallback; bad SQL grammar [SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAM
E = ? and JOB_KEY = ?]; nested exception is org.h2.jdbc.JdbcSQLException: Table "BATCH_JOB_INSTANCE" not found; SQL statement:
SELECT JOB_INSTANCE_ID, JOB_NAME from BATCH_JOB_INSTANCE where JOB_NAME = ? and JOB_KEY = ? [42102-194]


ํ…Œ์ด๋ธ”์„ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค๋Š” ๋ฉ”์‹œ์ง€์ธ๋ฐ, ์‹ค์ œ๋กœ ํ…Œ์ด๋ธ”์€ ์ƒ์„ฑ๋˜์–ด ์žˆ๋Š” ์ƒํƒœ๋„ค์š”.
๋น„์Šทํ•œ ๊ฒฝ์šฐ๋ผ๋„ ์žˆ์œผ์‹ ๋ถ„ ๊ณต์œ ํ•ด์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

--
์ด ๋ฉ”์ผ์€ Google ๊ทธ๋ฃน์Šค 'Korea Spring User Group Q&A' ๊ทธ๋ฃน์— ๊ฐ€์ž…ํ•œ ๋ถ„๋“ค์—๊ฒŒ ์ „์†ก๋˜๋Š” ๋ฉ”์‹œ์ง€์ž…๋‹ˆ๋‹ค.
์ด ๊ทธ๋ฃน์—์„œ ํƒˆํ‡ดํ•˜๊ณ  ๋” ์ด์ƒ ์ด๋ฉ”์ผ์„ ๋ฐ›์ง€ ์•Š์œผ๋ ค๋ฉด ksug+unsubscribe@googlegroups.com์— ์ด๋ฉ”์ผ์„ ๋ณด๋‚ด์„ธ์š”.
https://groups.google.com/group/ksug์—์„œ ์ด ๊ทธ๋ฃน์„ ๋ฐฉ๋ฌธํ•˜์„ธ์š”.
์›น์—์„œ ์ด ํ† ๋ก ์„ ๋ณด๋ ค๋ฉด https://groups.google.com/d/msgid/ksug/b6ae7650-02a7-43bb-8389-44cf5612bb56%40googlegroups.com์„(๋ฅผ) ๋ฐฉ๋ฌธํ•˜์„ธ์š”.
๋” ๋งŽ์€ ์˜ต์…˜์„ ๋ณด๋ ค๋ฉด https://groups.google.com/d/optout์„(๋ฅผ) ๋ฐฉ๋ฌธํ•˜์„ธ์š”.

๋ฌด์„ธ

unread,
Jun 8, 2017, 5:54:13โ€ฏAM6/8/17
to Korea Spring User Group Q&A
BATCH_JOB_INSTANCE ํ…Œ์ด๋ธ”์€ springbatch์—์„œ default๋กœ ๋งŒ๋“ค์–ด ๋‚ด๋Š” ํ…Œ์ด๋ธ”์ผํ…๋ฐ..

์•„๋ž˜์™€ ๊ฐ™์ด DefaultBatchConfigurer๋ฅผ ์ƒ์†๋ฐ›์•„ createJobRepository๋ฅผ overrideํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ํ…Œ์ด๋ธ”์ด ์ƒ์„ฑ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
์•„๋ž˜์™€ ๊ฐ™์ด ํ•˜๋ฉด ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์„๊ฑฐ ๊ฐ™์•„์š”...

@Configuration
@EnableBatchProcessing
public class AJobConfiguration extends DefaultBatchConfigurer {

@Override
protected JobRepository createJobRepository() throws Exception {
MapJobRepositoryFactoryBean factory =
new MapJobRepositoryFactoryBean();
factory.afterPropertiesSet();
return (JobRepository) factory.getObject();
}


2017๋…„ 6์›” 7์ผ ์ˆ˜์š”์ผ ์˜คํ›„ 6์‹œ 52๋ถ„ 41์ดˆ UTC+9, ๋ธ”๋ž™ ๋‹˜์˜ ๋ง:
ํ˜น์‹œ ๋Œ€์†Œ๋ฌธ์ž ๊ตฌ๋ถ„ํ•˜๊ฒŒ ์„ค์ •๋˜์–ด์žˆ์œผ์‹ ๊ฐ€์š”?

์ด ๊ทธ๋ฃน์—์„œ ํƒˆํ‡ดํ•˜๊ณ  ๋” ์ด์ƒ ์ด๋ฉ”์ผ์„ ๋ฐ›์ง€ ์•Š์œผ๋ ค๋ฉด ksug+uns...@googlegroups.com์— ์ด๋ฉ”์ผ์„ ๋ณด๋‚ด์„ธ์š”.
Reply all
Reply to author
Forward
0 new messages