application.yml中有数据库配置
#数据库配置
# datasource
spring:
datasource:
username: root
password: YY121
url: jdbc:mysql://localhost:3306/novel?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=UTC
driver-class-name: com.mysql.cj.jdbc.Driver
启动报错
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
解决方案
在App.java中@SpringBootApplication注解后添加exclude = DataSourceAutoConfiguration.class
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
完整代码
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class App extends SpringBootServletInitializer
{
public static void main(String[] args) throws Exception
{
SpringApplication.run(App.class, args);
}
}
启动成功