SweetInk / jrebel-mybatisplus

A hook plugin for Support MybatisPlus that reloads modified SQL maps.
MIT License
174 stars 33 forks source link

能否兼容一下mybatisplus 3.2和jrebel2019.2.1,sqlSessionFactory报空指针 #7

Closed Charles-Kai closed 4 years ago

Charles-Kai commented 5 years ago
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [config/spring/applicationContext-dao.xml]: Invocation of init method failed; nested exception is java.lang.NullPointerException
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1631)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:481)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:312)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:308)
        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:1136)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1064)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireByType(AbstractAutowireCapableBeanFactory.java:1347)
        ... 80 more
    Caused by: java.lang.NullPointerException
        at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.buildSqlSessionFactory(MybatisSqlSessionFactoryBean.java:510)
        at com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean.afterPropertiesSet(MybatisSqlSessionFactoryBean.java:426)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1689)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1627)
        ... 90 more
Charles-Kai commented 5 years ago
    <!-- Spring整合Mybatis,更多查看文档:http://mp.baomidou.com -->
    <bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <!-- 自动扫描Mapping.xml文件 -->
        <property name="mapperLocations" value="classpath:com/qm/mapper/*.xml"/>
        <property name="configLocation" value="classpath:config/mybatis/sqlMapConfig.xml"/>
        <property name="typeAliasesPackage" value="com.qm.po"/>
        <!-- 全局配置注入 -->
        <property name="globalConfig" ref="globalConfig"/>
    </bean>
    <bean id="globalConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig">
        <property name="dbConfig">
            <bean class="com.baomidou.mybatisplus.core.config.GlobalConfig.DbConfig">
                <property name="idType" value="AUTO"/>
            </bean>
        </property>
        <property name="metaObjectHandler">
            <bean class="com.qm.controller.common.MyMetaObjectHandler"/>
        </property>
    </bean>

    <!-- MyBatis 动态扫描  -->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.qm.mapper"/>
    </bean>
Charles-Kai commented 5 years ago

不管是idea插件还是源码构建jar,-Drebel.plugins=F:\github\jrebel-mybatisplus\target\jr-mybatisplus-1.0.1.jar,一样的报空指针异常,去掉插件和jvm参数引入jar包,正常运行,我认为是代理时候,xml关于sql配置未得到正确解析!

SweetInk commented 5 years ago

不管是idea插件还是源码构建jar,-Drebel.plugins=F:\github\jrebel-mybatisplus\target\jr-mybatisplus-1.0.1.jar,一样的报空指针异常,去掉插件和jvm参数引入jar包,正常运行,我认为是代理时候,xml关于sql配置未得到正确解析!

我在本地测试时(mybatis-plus:3.2.0,JRebel:2019.2.1)没有上述问题,你能否提供你的上述项目最小可运行环境(数据库+项目最小结构DEMO),方便我进行DEBUG

Charles-Kai commented 5 years ago

不好意思,我看见插件更新才知道。 @SweetInk 多谢,我以后也会加入开源共享

SweetInk commented 5 years ago

不好意思,我看见插件更新才知道。 @SweetInk 多谢,我以后也会加入开源共享

你的问题解决了吗?