Add a simple controller to a new SpringBoot project from SpringBoot Initializer , and the startup error is as follows:
. ____ _ __ _ _ /\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \ (()\___ |'_ |'_| |'_ \/ _` | \ \ \ \ \\/ ___)| |_)| | | | | || (_| |)))) '|____| .__|_| |_|_| |_\__, | / / / / ==========|_|==============|___/=/_/_/_/ :: Spring Boot :: (v2.1.8.RELEASE) 2019-09-09 10:37:16.750 INFO 11232 --- [ main] com.dongdong.demo.DemoApplication : Starting DemoApplication on PC-20170304VFOZ with PID 11232 (E:\Spring\Projects\demo\target\classes started by Administrator in E:\Spring\Projects\demo) 2019-09-09 10:37:16.752 INFO 11232 --- [ main] com.dongdong.demo.DemoApplication : No active profile set, falling back to default profiles: default 2019-09-09 10:37:17.711 INFO 11232 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data repositories in DEFAULT mode. 2019-09-09 10:37:17.730 INFO 11232 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 16ms. Found 0 repository interfaces. 2019-09-09 10:37:18.023 INFO 11232 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration' of type [org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration$$EnhancerBySpringCGLIB$$3d0e1f1a] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-09-09 10:37:18.327 INFO 11232 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http) 2019-09-09 10:37:18.359 INFO 11232 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat] 2019-09-09 10:37:18.360 INFO 11232 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.24] 2019-09-09 10:37:18.476 INFO 11232 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext 2019-09-09 10:37:18.476 INFO 11232 --- [ main] o.s.web.context.ContextLoader : Root WebApplicationContext: initialization completed in 1645 ms 2019-09-09 10:37:18.732 INFO 11232 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor' 2019-09-09 10:37:18.842 WARN 11232 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception; nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Failed to determine a suitable driver class 2019-09-09 10:37:18.843 INFO 11232 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor' 2019-09-09 10:37:18.846 INFO 11232 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat] 2019-09-09 10:37:18.860 INFO 11232 --- [ main] ConditionEvaluationReportLoggingListener : Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2019-09-09 10:37:18.864 ERROR 11232 --- [ 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 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
the reason
The application does not use DataSource, but introduces mybatis-spring-boot-starter in pom.xml
Problem solution
There are two types:
remove the dependency of mybatis-spring-boot-starter, so that it will not trigger the spring boot related
code disable the spring boot automatically initialize the DataSource related code
There are two ways to prohibit:
In the @SpringBootApplication of the startup class, add
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class })
Configure in application.properties:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration,org.springframework.boot.autoconfigure.jdbc.DataSourceTransactionManagerAutoConfiguration
Get it done!
Read More:
- [Solved] Springboot Error creating bean with name ‘dataSource’ defined in class path resource
- [Solved] SAX2 driver class org.apache.xerces.parsers.SAXParser not found
- [Solved] Springboot project Create to start Error: APPLICATION FAILED TO START
- How to Solve SpringBoot MongoDB MongoAutoConfiguration Startup Error
- SpringBoot Access Clickhouse Error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jdbcConverter’ defined in class path resource [***.class]
- [Solved] nacos Startup Error: Error creating bean with name ‘authFilterRegistration‘ defined in class path resource
- [Solved] Springboot Startup Error: Consider defining a bean of type ‘XXX’ in your configuration.
- [Solved] Springboot Error: org.apache.catalina.core.ContainerBase : A child container failed during start
- [Solved] Failed to bind properties under ‘spring.datasource.type‘ to java.lang.Class<javax.sql.DataSource>
- [Solved] SpringBoot Integrates Swagge Error: Failed to start bean ‘documentationPluginsBootstrapper‘
- [Solved] NVIDIA driver error: NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver…
- New Spring boot startup error Failed to auto-configure a DataSource
- SpringBoot High Version Import Swagger 2.9.2 Error: ApplicationContextException: Failed to start bean ‘documentationPluginsBootstrapper‘
- [Solved] The version of springcloud must support the current version of springboot, otherwise the startup project will report an error: error starting ApplicationContext
- [Solved] Docker failed to start daemon: error initializing graphdriver: driver not supported
- Tomcat startup error: Failed to start component [StandardServer[8005]] solution
- [Solved] Springcloud Add gateway to Startup Error: Exception encountered during context initialization – cancelling refresh
- [Solved] Swagger Startup Error: Failed to start bean ‘documentationPluginsBootstrapper‘
- [Solved] Springboot Project Startup Error: Error starting ApplicationContext
- Springboot running shows application run failed [How to Solve]