Quantcast

Integration Spring3 multi datasource problem

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Integration Spring3 multi datasource problem

sivyer
This post has NOT been accepted by the mailing list yet.

error stack:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'ipService': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.sivyer.app.number.persistence.ip.IpMapper com.sivyer.app.number.service.IpService.mapper; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.sivyer.app.number.persistence.ip.IpMapper] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:285)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1074)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:580)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:425)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
        at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
        at com.sivyer.util.AppContext.<clinit>(AppContext.java:10)

Integration lib:
Spring 3.1
mybatis-spring-1.1

my spring config file :

<bean id="ipDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                <property name="driverClassName" value="com.mysql.jdbc.Driver" />
                <property name="url" value="jdbc:mysql://localhost/ip?useUnicode=true&amp;characterEncoding=utf8" />
                <property name="username" value="root" />
                <property name="password" value="root" />
        </bean>
       
        <bean id="mobileDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
                <property name="driverClassName" value="com.mysql.jdbc.Driver" />
                <property name="url" value="jdbc:mysql://localhost/mobile?useUnicode=true&amp;characterEncoding=utf8" />
                <property name="username" value="root" />
                <property name="password" value="root" />
        </bean>
       
       
       
    <bean id="ipSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
                <property name="dataSource" ref="ipDataSource" />
                <property name="typeAliasesPackage" value="com.sivyer.app.number.domains.ip" />
                <property name="transactionFactory">
                        <bean class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" />
                </property>
        </bean>   
       
        <bean id="mobileSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
                <property name="dataSource" ref="mobileDataSource" />
                <property name="typeAliasesPackage" value="com.sivyer.app.number.domains.mobile" />
                <property name="transactionFactory">
                        <bean class="org.apache.ibatis.transaction.managed.ManagedTransactionFactory" />
                </property>
        </bean> 
         
       
    <context:component-scan base-package="com.sivyer.app.number.service" />
   
   
    <context:annotation-config />

   
    <tx:annotation-driven />

   
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
   
        <property name="basePackage" value="com.sivyer.app.number.persistence" />
    </bean>



need help.
thanks!!
Loading...