SpringCloud启动服务提供者报错DataSourse
报错信息:
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).
Process finished with exit code 1
导致错误的原因:
在provider模块的pom.xml中,添加了pom的打包方式:
再来到target文件夹下,发现只有类,原来的application.yml文件不见了
正确的目录结构应如下图所示:
解决方法:
删掉<packaging>pom</packaging>
或者将pom改为jar或war的形式:
<packaging>jar</packaging>
总结:
- 凡是要运行的项目,都要保证它的打包方式是jar或war,默认是jar
- 如果是pom包,表示是不可运行的
- pom导致运行的时候一直读不到application配置文件
- 解决步骤:
- 把pom依赖删掉
- 清空target的目录,重新rebuild模块
- 重新编译后,target中有配置文件就行了
报以上错误的,解决思路:
1.查看target有没有编译进配之文件
2.到pom中查看打包方式
3.右键查看resources的Mark Directory as是否为"Resources Root"