Coder Social home page Coder Social logo

Comments (5)

abel533 avatar abel533 commented on June 24, 2024

jdbcurl 怎么配置的?

from pagehelper-spring-boot.

luckypolaris avatar luckypolaris commented on June 24, 2024

不引入starter包 把PageHelperAutoConfiguration这个类的代码拷贝出来,注释掉@ConditionalOnBean(SqlSessionFactory.class) 就不报错了,不知道什么原因
`@Configuration
//@ConditionalOnBean(SqlSessionFactory.class)
@EnableConfigurationProperties(PageHelperProperties.class)
public class PageHelperAutoConfig{

    @Autowired
    private List<SqlSessionFactory> sqlSessionFactoryList;

    @Autowired
    private PageHelperProperties properties;

    /**
     * 接受分页插件额外的属性
     *
     */
    @Bean
    @ConfigurationProperties(prefix = PageHelperProperties.PAGEHELPER_PREFIX)
    public Properties pageHelperProperties() {
            return new Properties();
    }

    @PostConstruct
    public void addPageInterceptor() {
            PageInterceptor interceptor = new PageInterceptor();
            Properties properties = new Properties();
            //先把一般方式配置的属性放进去
            properties.putAll(pageHelperProperties());
            //在把特殊配置放进去,由于close-conn 利用上面方式时,属性名就是 close-conn 而不是 closeConn,所以需要额外的一步
            properties.putAll(this.properties.getProperties());
            interceptor.setProperties(properties);
            for (SqlSessionFactory sqlSessionFactory : sqlSessionFactoryList) {
                    sqlSessionFactory.getConfiguration().addInterceptor(interceptor);
            }
    }

}`

from pagehelper-spring-boot.

abel533 avatar abel533 commented on June 24, 2024

这种情况只能针对代码调试找原因了。

from pagehelper-spring-boot.

qinaren avatar qinaren commented on June 24, 2024

我也碰到这个问题了,我用的是sharding sphere。在application.yml中并没有配置spring.datasource,配置的是spring.shardingsphere.datasource。//@ConditionalOnBean(SqlSessionFactory.class)就行了

from pagehelper-spring-boot.

qinaren avatar qinaren commented on June 24, 2024

如果是自定义的 datasource (例如使用mycat) 并且是自己写的datasource AutoConfig
没用 pagehelper-spring-boot-start时 正常使用。
引入start后,会报如下错误,怎么破?

APPLICATION FAILED TO START

Description:

Cannot determine embedded database driver class for database type NONE

Action:

If you want an embedded database please put a supported one on the classpath. If you have database settings to be loaded from a particular profile you may need to active it

其实是Configuration加载顺序的问题,你自己定义的starter中的Configuration加载在PageHepler的Configuration之后了,造成了SpringBoot先加载了自己的DS 的Configuration,所以报错。在你自己的Configuration中加上@AutoConfigureBefore(DataSourceAutoConfiguration.class)这个就OK了。

from pagehelper-spring-boot.

Related Issues (20)

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.