SpringBoot没有读取到application.yml问题及解决
1.遇到的问题
***************************
APPLICATION FAILED TO START
***************************Description:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class
Action:Consider the following:
If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).
其实我的application.yml文件配置的一点问题都没有,依赖也依赖够了,可是还是报这个错。
2.发现问题
由于application.xml实在controller模块下的,
结果发现pom.xml的配置里面有一条配置是这样的
<packaging>pom</packaging>
由于这里配置错了pom导致我读取不到resources的配置文件,所以才会报错。
3.改正
<packaging>war</packaging>
然后重新刷新maven,运行项目

总结
以上为个人经验,希望能给大家一个参考,也希望大家多多支持脚本之家。
- SpringBoot中application.properties与application.yml区别小结
- SpringBoot中读取application.properties配置文件的方法
- 解决SpringBoot加载application.properties配置文件的坑
- 解决springboot application.properties server.port配置问题
- SpringBoot application.yml和bootstrap.yml的区别
- springboot读取application.yaml文件数据的方法
- SpringBoot中application.properties、application.yaml、application.yml区别
相关文章
IDEA如何使用spring-Initializr快速搭建SpringBoot
这篇文章主要介绍了IDEA如何使用spring-Initializr快速搭建SpringBoot问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教2024-05-05
java web开发中大量数据导出Excel超时(504)问题解决
开发测试时候导入数据遇到大数据导入的问题,整理了下,需要的朋友可以参考下2017-04-04


最新评论