Cannot resolve class or package
2018-10-22 本文已影响0人
然也翰飞
使用Spring Boot 整合MySQL的时候配置可能会出现这个故障:
Cannot resolve class or package ‘jdbc’ less… (Ctrl+F1) Inspection
info: Checks Spring Boot application .properties configuration files.
Highlights unresolved and deprecated configuration keys and invalid
values.

故障分析:
其实这个问题是由于MySQL 这个jar 包依赖类型默认是runtime , 即只有运行时生效。
网上资料说:虽然这里报错,但是不影响你代码运行。 (实际上在我的项目中出错了)


解决方案:
一、将runtime 修改为Compile 即可
1.选中项目—> 右键—–> Open Module Settings

2.Modules ——> *****App ——-> Dependencies

3.将runtime 修改为Compile即可

二、在porm中直接删除“runtime”


两种解决方案本质上是一样的。