开发者社区> 问答> 正文

springboot整合druid,项目中有接口后druid配置为空启动报错问题?报错

项目没有创建interface文件的时候启动是正常的,项目中如果新建一个接口文件如图中的IUserService,启动项目报错:

Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'IUserService' defined in file [E:\fqtx-springboot\fqtx\target\classes\net\webloo\service\IUserService.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [org/mybatis/spring/boot/autoconfigure/MybatisAutoConfiguration.class]: Unsatisfied dependency expressed through method 'sqlSessionFactory' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'druidDataSource' defined in class path resource [net/webloo/utils/config/DruidAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [javax.sql.DataSource]: Factory method 'druidDataSource' threw exception; nested exception is java.lang.IllegalArgumentException: maxActive can't not set zero

也就是说只有项目里存在一个自定义接口文件,获取配置文件就获取不到,这是啥原因

展开
收起
爱吃鱼的程序员 2020-06-08 10:36:32 2892 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    maxActivecan'tnotsetzero,这是最后的原因

    我问题里说了啊,如果加了interface文件,配置文件获取不到maxActive肯定是0啊,如果项目里没有写interface文件,就没有这个问题,可以获取配置文件的配置属性
    @Component

    加上这个呢

    找到问题了,是因为我pom.xml里面加了spring-boot-devtools这个热部署依赖,这个依赖删了就没事了,但是这样我就用不了热部署了啊。。
    2020-06-08 10:36:46
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
Java Spring Boot开发实战系列课程【第15讲】:Spring Boot 2.0 API与Spring REST Docs实战 立即下载
Apache Dubbo3 源码深入解读 立即下载
Java Spring Boot开发实战系列课程【第6讲】:Spring Boot 2.0实战MyBatis与优化(Java面试题) 立即下载

相关实验场景

更多