FactoryBeans and the annotation-based configuration in Spring 3.0

后端 未结 6 1655
-上瘾入骨i
-上瘾入骨i 2020-12-24 14:13

Spring provides the FactoryBean interface to allow non-trivial initialisation of beans. The framework provides many implementations of factory beans and -- when

6条回答
  •  囚心锁ツ
    2020-12-24 14:46

    Why do you not inject the Factory in your AppConfiguration?

    @Configuration
    public class AppConfig {
    
        @Resource
        private SqlSessionFactoryBean factory;
    
        @Bean 
        public SqlSessionFactory sqlSessionFactory() throws Exception {
           return factory.getObjectfactory();    
        }    
    }
    

    But may I did not understand your question correct. Because it looks to me that you are trying something strange - go a step back and rethink what are you really need.

提交回复
热议问题