오류명 : Exception in thread "main" java.lang.NoClassDefFoundError: org/springframework/util/ConcurrentReferenceHashMap
오류원인 :
1. DB 정보 오입력
2. ComponentScan Value 오입력
오류해결 :
1. DB 정보 수정(동일)
2. ComponentScan Value 변경 후 해결
아래 클래스에서 ClassPathResource를 잘못 적음
package com.springBatch05.main.config;
import javax.sql.DataSource;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.core.env.Environment;
import org.springframework.core.io.ClassPathResource;
import org.springframework.jdbc.datasource.DriverManagerDataSource;
import org.springframework.jdbc.datasource.init.DataSourceInitializer;
import org.springframework.jdbc.datasource.init.ResourceDatabasePopulator;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
@Configuration
@EnableBatchProcessing
@EnableScheduling
@ComponentScan("com.springBatch04.main")
@PropertySource("classpath:/batch.properties")
public class BatchConfiguration {
@Autowired
private Environment env;
@Bean
public DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setUrl(env.getRequiredProperty("dataSource.url"));
dataSource.setUsername(env.getProperty("dataSource.username"));
dataSource.setPassword(env.getProperty("dataSource.password"));
return dataSource;
}
@Bean
public DataSourceInitializer databasePopulator() {
ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
populator.addScript(new ClassPathResource("org/springframework/batch/core/schema-h2.sql"));
populator.addScript(new ClassPathResource("sql/insert.sql"));
populator.setContinueOnError(true);
populator.setIgnoreFailedDrops(true);
DataSourceInitializer initializer = new DataSourceInitializer();
initializer.setDatabasePopulator(populator);
initializer.setDataSource(dataSource());
return initializer;
}
}
다음과 같이 수정 후 문제 해결
1번 방법대로 진행하였으나 동일한 문제가 발생였다.
2. ComponentScan Value 변경
변경 후 문제를 해결하였다.