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>