Giter VIP home page Giter VIP logo

async-excel's Issues

mybatisplus的globalConfig冲突。(不清楚是不是bug,)

场景是这样的:我的项目配置了一个 mybatplus填充器。

  /**
     * 填充 创建人、更新人信息
     */
    @Bean
    public MetaObjectHandler metaObjectHandler() {
        return new CreatorAndUpdatorInfoHandler();
    }

但是我发现没有生效,debug之后发现,是async的GlobalConfig 把项目中的GlobalConfig替换了,这样我的MetaObjectHandler 就失效了。

/**
 * @Description TODO
 * @Author 姚仲杰#80998699
 * @Date 2022/7/5 16:37
 */
@Configuration
@MapperScan(value = "com.asyncexcel.springboot.context.mapper",sqlSessionFactoryRef = "excelSqlSessionFactory")
@EnableConfigurationProperties({ExcelDataSourceProperties.class,MybatisPlusProperties.class})
public class ExcelMybatisPlusConfiguration {
    
    @Bean("excelDataSource")
    public DataSource dataSource(ExcelDataSourceProperties properties){
        HikariDataSource hikariDataSource = new HikariDataSource();
        hikariDataSource.setJdbcUrl(properties.getUrl());
        hikariDataSource.setUsername(properties.getUsername());
        hikariDataSource.setPassword(properties.getPassword());
        hikariDataSource.setDriverClassName(properties.getDriverClassName());
        return hikariDataSource;
    }
    
    @Bean("excelSqlSessionFactory")
    public SqlSessionFactory sqlSessionFactory(@Qualifier("excelDataSource") DataSource dataSource) throws Exception {
        MybatisSqlSessionFactoryBean mybatisSqlSessionFactoryBean = new MybatisSqlSessionFactoryBean();
        mybatisSqlSessionFactoryBean.setVfs(SpringBootVFS.class);
        mybatisSqlSessionFactoryBean.setDataSource(dataSource);
        GlobalConfig globalConfig = new GlobalConfig();
        DbConfig dbConfig = new DbConfig();
        dbConfig.setIdType(IdType.AUTO);
        globalConfig.setDbConfig(dbConfig);

        mybatisSqlSessionFactoryBean.setGlobalConfig(globalConfig);
        return mybatisSqlSessionFactoryBean.getObject();
    }
    
}

setGlobalConfig 导致我的失效了?没有仔细debug去看源码了,结果是前端提交一片报错 ,因为我的表的createDt等字段都是自动填充的。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.