Spring-Batch
01. SpringBatch 빠르게 시작하기
Joh n
2024. 10. 6. 15:55
IDE : IntelliJ IDEA Ultimate
Java Version : 17
Spring Boot Version : 3.3.4
Build : Gradle
스프링 배치를 사용해보기 위해서 프로젝트를 생성했습니다.
인텔리제이 내부에서 프로젝트를 생성하였습니다.
프로젝트에 사용하던 JDK와 빌드를 변경하기 위해서 들어가보았습니다.
컴퓨터에 설치된 JDK 17으로 변경하였고, Build 설정을 IntelliJ IDEA로 변경하였습니다.
빌드 툴을 변경한 이유 : IntelliJ IDEA 내에서 빌드 시 실행이 더 빠름
바로 실행시켜보았습니다.
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.3.4)
2024-10-06T15:05:47.020+09:00 INFO 68817 --- [ main] o.s.s.sample.SampleApplication : Starting SampleApplication using Java 17.0.7 with PID 68817 (/Users/amazon/lunch/스프링배치스터디/01/sample/out/production/classes started by amazon in /Users/amazon/lunch/스프링배치스터디/01/sample)
2024-10-06T15:05:47.021+09:00 INFO 68817 --- [ main] o.s.s.sample.SampleApplication : No active profile set, falling back to 1 default profile: "default"
2024-10-06T15:05:47.223+09:00 WARN 68817 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceConfiguration$Hikari] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-10-06T15:05:47.235+09:00 WARN 68817 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-10-06T15:05:47.236+09:00 WARN 68817 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration$PooledDataSourceConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-10-06T15:05:47.236+09:00 WARN 68817 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'jdbcConnectionDetails' of type [org.springframework.boot.autoconfigure.jdbc.PropertiesJdbcConnectionDetails] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-10-06T15:05:47.238+09:00 WARN 68817 --- [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.batch.BatchAutoConfiguration$SpringBootBatchConfiguration': Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception with message: Failed to determine a suitable driver class
2024-10-06T15:05:47.242+09:00 INFO 68817 --- [ main] .s.b.a.l.ConditionEvaluationReportLogger :
Error starting ApplicationContext. To display the condition evaluation report re-run your application with 'debug' enabled.
2024-10-06T15:05:47.247+09:00 ERROR 68817 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:
Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
Process finished with exit code 1
DataSource가 필요하다고 합니다.
DataSource 구성
MemoryDB라는 것을 이용하도록 설정하였습니다.
MemoryDB?
매우 빠른 성능을 제공하는 내구성이 뛰어난 인메모리 데이터베이스
H2 Database 설치
dependencies에 종속성 추가
implementation 'com.h2database:h2:2.2.224'
application.properties를 삭제하고 application.yaml 생성하여 아래 내용을 추가합니다.
# H2 DataBase용
spring:
datasource:
hikari:
maximum-pool-size: 10
url: jdbc:h2:mem:testdb
driver-class-name: org.h2.Driver
username: sa
password: password
EnableBatchProcessing 어노테이션을 Application 클래스에 추가합니다.
참고한 글에는 gradle :bootRun 와 같은 명령으로 실행하고 있습니다.
gradle :bootRun
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :bootRun
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.3.4)
2024-10-08T09:28:16.628+09:00 INFO 21061 --- [ main] o.s.s.sample.SampleApplication : Starting SampleApplication using Java 17.0.5 with PID 21061 (/Users/amazon/lunch/스프링배치스터디ample/build/classes/java/main started by amazon in /Users/amazon/lunch/스프링배치스터디/01-1/sample)
2024-10-08T09:28:16.629+09:00 INFO 21061 --- [ main] o.s.s.sample.SampleApplication : No active profile set, falling back to 1 default profile: "default"
2024-10-08T09:28:16.781+09:00 INFO 21061 --- [ main] o.s.b.c.c.annotation.BatchRegistrar : Finished Spring Batch infrastructure beans configuration in 1 ms.
2024-10-08T09:28:16.891+09:00 WARN 21061 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'jobRegistry' of type [org.springframework.batch.core.configuration.support.MapJobRegistry] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [jobRegistryBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.
2024-10-08T09:28:16.944+09:00 INFO 21061 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2024-10-08T09:28:17.024+09:00 INFO 21061 --- [ main] com.zaxxer.hikari.pool.HikariPool : HikariPool-1 - Added connection conn0: url=jdbc:h2:mem:8ca49aa1-59c1-49f2-853e-f325b8e47b79 user=SA
2024-10-08T09:28:17.024+09:00 INFO 21061 --- [ main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2024-10-08T09:28:17.030+09:00 INFO 21061 --- [ main] o.s.b.c.r.s.JobRepositoryFactoryBean : No database type set, using meta data indicating: H2
2024-10-08T09:28:17.044+09:00 INFO 21061 --- [ main] o.s.b.c.l.support.SimpleJobLauncher : No TaskExecutor has been set, defaulting to synchronous executor.
2024-10-08T09:28:17.097+09:00 INFO 21061 --- [ main] o.s.s.sample.SampleApplication : Started SampleApplication in 0.618 seconds (process running for 0.761)
2024-10-08T09:28:17.100+09:00 INFO 21061 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2024-10-08T09:28:17.100+09:00 INFO 21061 --- [ionShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
BUILD SUCCESSFUL in 11s
빌드 성공
Reference
https://devocean.sk.com/blog/techBoardDetail.do?ID=166164
[SpringBatch 연재 01] SpringBatch 빠르게 시작하기
devocean.sk.com