最近在做一个 SpringBoot 的项目,用到了数据库。所以在 yml 中配置了 driver-class-name: com.mysql.jdbc.Driver。但是保存之后,yml 文件提示:Cannot resolve class or package ‘jdbc’ less…
详细内容如下:
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.
这个错误的大概意思是说:无法解析 jdbc 类或包。
说白了,就是没有找到 com.mysql.jdbc.Driver 这个东西。
虽然这个错误,并不影响运行。但是看起来特别别扭!
于是,我看了我的 pom.xml 文件中引入了 mysql-connector-java。唯一的可能就是 scope 配置的不对。
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency>
然后,我把 scope 配置去掉,或者改成 compile 后,错误就消失了,问题就解决了!
: » 解决 Springboot 配置文件提示 Cannot resolve class or package ‘jdbc’ less… 问题
原创文章,作者:Carrie001128,如若转载,请注明出处:https://blog.ytso.com/tech/aiops/252829.html