1. 报错场景
邮件服务不需要连接数据库, 但是底层包中引入了
包
org.mybatis.spring.boot
mybatis-spring-boot-starter
2. 报错
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2021-12-10 17:08:49.976 ERROR 12188 --- [ main] 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 classAction: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).Disconnected from the target VM, address: '127.0.0.1:61178', transport: 'socket'Process finished with exit code 1
3. 处理方案:
3.1 配置文件中设置数据库连接信息
spring:application:name: ml-finance-servicedatasource:driver-class-name: com.mysql.cj.jdbc.Driverurl: jdbc:mysql://****/**?allowMultiQueries=true&serverTimezone=GMT%2B8&characterEncoding=utf8username: mlpassword: Ml123456..
3.2 启动类设置 @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
/*** @author ml*/@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})@ComponentScan("com.ml")public class MailApplication extends SpringBootServletInitializer {public static void main(String[] args) {new SpringApplicationBuilder(MailApplication.class).run(args);}}
