springboot/cloud的appliaction.yml的配置注意事项

2 篇文章 0 订阅
2 篇文章 0 订阅

首先springcloud的官方推荐使用.yml的格式。
然后我就首次使用了.yml格式的配置文件。
然后遇到了首大坑。
首先这是我写的格式:
在这里插入图片描述
然后疯狂报错:
在这里插入图片描述

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-03-12 14:41:45.766 ERROR 99744 --- [  restartedMain] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
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).


Process finished with exit code 0

大致意思是说:
没有指定"url"属性,无法配置任何嵌入式的数据源。
原因是:未能确定合适的驱动程序类。

关键是我的配置文件的内容再三检查了,没有写错一个字母。这我就好奇了。
然后疯狂百度,
有的说是没有用datasource连接数据库。注释掉maven的jar包
在这里插入图片描述
还有的说是只是掉启动类的一些参数。在启动类的@EnableAutoConfiguration或@SpringBootApplication中添加exclude = {DataSourceAutoConfiguration.class},排除此类的autoconfig。启动以后就可以正常运行。但是都没有用。

@MapperScan("com.wsc.core.mapper")//映射mapper地址
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
  //启动类 SpringBoot
public class Start {
    public static void main(String[] args) {
        SpringApplication.run(Start.class,args);
    }
}

然后还有说是mysql的驱动类jar包出错了,需要手动的添加jar包驱动
在这里插入图片描述在这里插入图片描述在这里插入图片描述
在这里插入图片描述依然米有用。
最后发现是格式的错误。
在这里插入图片描述
datasource需要个application对齐。
我第一次的格式为:在这里插入图片描述然后找了一上午,没有发现,毕竟第一次使用,错误印象深刻呀。
特此记录!!!防止再犯。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值