springboot启动报错:Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.

springboot启动报错:

报错一: 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

***************************
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 1

解决: @SpringBootApplication(scanBasePackages = {"com.ks"})

        //为什么加这个的原因:com.ks.school.SchoolApp,只扫描com.ks.school包里的@Configuration
        //而DruidConfig的包名是:com.ks.config.druid

所以,SchoolApp最好写在com.ks包下。而School业务相关的controller、service放在com.ks.school包下

报错三:A component required a bean named 'auditorAware' that could not be found.

解决:

@EnableJpaAuditing(auditorAwareRef = "auditorAware")
创建一个:
import org.springframework.data.domain.AuditorAware;
import org.springframework.stereotype.Component;
@Component("auditorAware")
public class AuditorConfig implements AuditorAware<String> {

报错二:org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.context.ApplicationContextException:

Unable to start ServletWebServerApplicationContext due to missing ServletWebServerFactory bean.

解决:

 【1】无@SpringBootApplication   
 【2】无   
 <dependency>   
 <groupId>org.springframework.boot</groupId>   
 <artifactId>spring-boot-starter-web</artifactId>   
 </dependency>   

报错三:Could not resolve placeholder 'druid.type' in value "${druid.type}"

解决:druid的配置必须放在:application.yml里面,不能放bootstrap.yml里面

报错四:java.sql.SQLException: url not set。

解决:application.yml里面配置少了product的数据源,加上就好了

end