Java Springcloud项目bug记录过程01
1.Failed to configure a DataSource
springcloud项目启动时,启动报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
分析:application.yml文件中已经配置了数据库
datasource: url: jdbc:mysql://localhost:3306/day1?serverTimezone=UTC&useSSL=false username: root password: ****** driver-class-name: com.mysql.cj.jdbc.Driver
解决方案:通过分析发现,application.yml文件idea并未识别,进行手动添加。
此时,项目的application.yml文件被识别。
2.IDEA run或debug 点击无反应?
然后尝试点击toolbar 上的run 按钮,run变成灰色了。。。
点击debug 按钮,debug变成灰色了。。。
再试一下后边的按钮。。。
原因:kotlin依赖冲突
我是添加了OkHttp3,但是发现里面也是添加了kotlin包,我的idea也是2018.1版本,,,,,然后我是将kotlin排除了,然后就可以了
<dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib-common</artifactId> <version>1.3.41</version> </dependency>
3.springboot项目中提示报错Cannot resolve configuration property 'spring.datasource.xxxx' 和hikari配置属性
druid和druid-spring-boot-starter区别分析:
(1)作用是一样的,都是连接池提供连接,里边的配置参数都是一样的;
(2)druid-spring-boot-starter只是在druid基础上进行了一次封装,专门用来整合spring-boot项目;
如果springboot项目想使用druid也是可以的,但是需要手动编写配置类并注入到bean中,并加载对应的配置参数;但是不建议,明明有现成封装好的jar,就直接使用就好了!!!
出现如下报错:
原因是没有导入druid-spring-boot-starter依赖。
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> </dependency>
总结:
①springboot项目整合druid,建议使用druid-spring-boot-strater,但是不代表druid一定不可以使用,有兴趣的可以自己试试
②配置yaml文件时,一定要使用druid下边的参数,要不然不起作用
4.mybatis-plus某个包没有被扫描进来,报错
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'bsClientSubsysServiceImpl': Unsatisfied dependency expressed through field 'baseMapper'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.ttbank.flep.admin.mapper.BsClientSubsysMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.ttbank.flep.admin.mapper.BsClientSubsysMapper' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoMatchingBeanFound(DefaultListableBeanFactory.java:1658)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1217
... 19 common frames omitted
解决方案:添加扫描
@MapperScan("com.ttbank.flep.admin.mapper")
5.‘org.jeecg.common.api.CommonAPI' not be found 错误解决办法
模块中引入其他依赖,需要使用feign功能
*************************** APPLICATION FAILED TO START *************************** Description: Field commonAPI in org.jeecg.common.aspect.DictAspect required a bean of type 'org.jeecg.common.api.CommonAPI' that could not be found. The injection point has the following annotations: - @org.springframework.beans.factory.annotation.Autowired(required=true) Action: Consider defining a bean of type 'org.jeecg.common.api.CommonAPI' in your configuration.
bug原因分析:
由于jeecg-boot创建的cloud项目中引入了
<dependencies> <dependency> <groupId>org.jeecgframework.boot</groupId> <artifactId>jeecg-boot-base-core</artifactId> </dependency> <!--引入微服务启动依赖 starter--> <dependency> <groupId>org.jeecgframework.boot</groupId> <artifactId>jeecg-boot-starter-cloud</artifactId> </dependency> </dependencies>
微服务启动依赖jeecg-boot-starter-cloud使用的feign,
解决方案:在FlepAdminApplication添加注解@EnableFeignClients(basePackages = "org.jeecg")
参考文献:
https://zhuanlan.zhihu.com/p/75231714
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)