잘가
292
2018-04-04 11:39:03
2
502

Error creating bean with name 'sqlSession' 에러가 뜹니다..


Caused by: org.springframework.beans.factory.BeanCurrentlyInCreationException: Error creating bean with name 'sqlSession': Requested bean is currently in creation: Is there an unresolvable circular reference?
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.beforeSingletonCreation(DefaultSingletonBeanRegistry.java:347)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:223)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
	at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:208)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1066)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1342)
	... 71 more

 이러한 에러가 뜹니다. 다른에러들도 연달아 뜨긴 하는데... 맨 아래 내용이 이건데요...

아마 이 두 코드쪽에서 나는 에러라고 생각하는데.. 잘 모르겠습니다. 조언 부탁드립니다.


sqlSession 빈 설정쪽은 이쪽이고..


public class DataSourceConfig {

	@Bean
	public DataSource dataSource() {
		BasicDataSource dataSource = new BasicDataSource();
		dataSource.setDriverClassName("oracle.jdbc.driver.OracleDriver");
		dataSource.setUrl("jdbc:oracle:thin:@192.168.252.130:1521:orcl");
		dataSource.setUsername("SystemManager");
		dataSource.setPassword("SystemManager");

		return dataSource;

	}

	@Bean
	public DataSourceTransactionManager transactionManager() {
		return new DataSourceTransactionManager(dataSource());
	}

	// sqlsession 사용하기 위해 추가
	@Bean
    public SqlSessionTemplate sqlSession(SqlSessionFactory sqlSessionFactory) {
        return new SqlSessionTemplate(sqlSessionFactory);
    }
	
	
	public SqlSessionFactoryBean sqlSessionFactoryBean() throws Exception {
		SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
		sessionFactory.setDataSource(dataSource());
		// 이 부분은 mybatis mapper 위치에 대해서 설정해주는 부분...
		sessionFactory.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:mapper/*.xml"));
		return sessionFactory;
	}
	

 사용하기 위해 쓴 코드는 아래입니다.



@Repository
public class ArticleDaoImpl implements ArticleDao{
 
	@Autowired
	private SqlSession sqlSession;
	
	// ArticleListMapper 의 namespace 값
	private static final String namespace = "mapper.ArticleListMapper";
    
	@Override
	public List<Article> articleSelectAll(String queryId, Object params){
		return sqlSession.selectList(namespace+".getArticleList", params);
	}
}


0
0
  • 답변 2

  • antop
    907
    2018-04-04 12:08:51

    https://www.google.co.kr/search?ei=r0HEWrL5KsOn0gSEhr-wDQ&q=Requested+bean+is+currently+in+creation%3A+Is+there+an+unresolvable+circular+reference&oq=Requested+bean+is+currently+in+creation%3A+Is+there+an+unresolvable+circular+reference&gs_l=psy-ab.3..0i67k1j0l2j0i5i30k1l7.4638.7211.0.7428.5.5.0.0.0.0.114.479.4j1.5.0....0...1.1j4.64.psy-ab..0.5.479....0.CVEU4g5VhVQ

    0
  • 잘가
    292
    2018-04-04 13:23:41

    antop

    autowired 가 안먹힌다는건 알고있는데요... 이게 왜 안먹히는건지 잘 모르겠어서 여쭈어본거에요

    질문을 잘못드려 죄송합ㄴㅣ다.

    0
  • 로그인을 하시면 답변을 등록할 수 있습니다.