When using spring cloud, we first create a parent project, and then add Eureka server module and SMS module, which run normally. Finally, after adding the payment module (mybatis and MySQL need to be integrated), the Eureka server module and SMS module report an error:
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).
After investigation, because mybatis jar package is introduced:
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.1</version>
</dependency>
Spring boot will load by default org.springframework.boot . autoconfigure.jdbc.DataSourceAutoConfiguration code> and the datasourceautoconfiguration class uses the @ configuration annotation to inject datasource into spring Bean, and because there is no configuration information about datasource in the project (Eureka server module and SMS module), when spring creates datasource bean, it will report an error due to lack of relevant information.
terms of settlement:
1. Add exclude to the @ springbootapplication annotation to release the automatic loading of datasourceautoconfiguration.
@EnableEurekaServer
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
2. In the pom.xml The common jar dependencies of all sub modules are stored in the file, and the non common dependencies are stored in the file of each module itself pom.xml It is stated in the document. The advantage of this method is that the dependence of each module will not interfere with each other.
Read More:
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded datasource could
- Failed to configure a DataSource: ‘ url’ attribute
- Springboot startup error failed to configure a datasource
- Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded (How to Fix)
- Failed to configure a DataSource: ‘url‘ attribute is not specified and no embedded
- Datasource bean injection failed, with startup error
- UITableView failed to obtain a cell from its dataSource?
- No qualifying bean of type ‘javax.sql.DataSource‘ available: expected at least 1
- Error creating bean with name ‘datasource’ defined in class path resource
- Configure Nvidia graphics card on ubuntu18.04 xrandr Failed to get size of gamma for output default
- How to Configure DHCP for Multiple VLANs?
- Vs configure tensorrt environment to use
- How to configure OpenGL on CodeBlocks
- MySQL installation failed: dpkg: error processing package MySQL server (- – configure): dependency problem
- The simplest way to configure OpenGL development environment with vs2015
- 1 vs20152017 + OpenGL to configure and draw a white rectangle
- How to configure OpenGL with CodeBlocks in Ubuntu
- How to Configure Inter VLAN Routing on Layer 3 Switches?
- No artifacts package solution for idea to configure Tomcat
- Configure eslint in vscode to automatically repair and save the code