Error creating bean with name ‘dataSourceScriptDatabaseInitializer’ defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method ‘dataSourceScriptDatabaseInitializer’ parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘dataSource’ defined in class path resource
Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Unsatisfied dependency expressed through method 'dataSourceScriptDatabaseInitializer' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource
The reason for my error is that I made an error when using @springboottest automatic injection when I first learned spring data JPA
@SpringBootTest
//springbootTest The server is not turned on by default,
public class MainTest {
@Autowired
UserRepository userRepository;
@Test
void t1(){
System.out.println(userRepository);
}
}
I searched the Internet for several hours and debugged it. I found that the datasource was always empty, because it was tested and run in the test method at that time, and the errors given were always the same as above. However, I clearly configured the database in application.yml, and later found it during overall debugging, Failed to load driver class com.mysql.cj.jdbc.driver in either of hikariconfig class loader or thread context classloader
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.25</version>
</dependency>
Of course, it may also be due to other errors. If you also encounter this error, you can see whether you have added MySQL dependencies to your dependencies
Read More:
- Error creating foreign key in MySQL: 1215 cannot add the foreign key constraint
- Using Mybatis to connect to the database error: Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver···
- [Solved] Sqlyog always reports an error when creating a new connection.
- [Solved] Django configures MySQL Error: NameError: name ”_MySQL ‘is not defined
- PLSQL environment variable configuration tnsnames.ora file path
- [Solved] Critical: Error configuring application listener of class org.springframework.web.context.ContextLoaderListener
- Problems in connecting mysql8.0 in IDEA [How to Solve]
- [Solved] there are special symbols in the initial password for installing MySQL in Hadoop, and an error is reported
- [Solved] java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corres
- [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file ./ibdata
- MySQL Error: [ERROR] [FATAL] InnoDB: Table flags are 0 in the data dictionary but the flags in file
- [Solved] public key is not available client side (option serverRsaPublicKeyFile not set)
- Linux Error: [ERROR] –initialize specified but the data directory has files in it. Aborting.
- [Solved] Error in MySQL installation in Linux: failed dependencies xxxxx
- Cannot resolve classpath entry: e://jar/mysql-connector-java-5.1.17-bin mybatis error in reverse engineering
- postgresql-Database query problem-ERROR: column “t.domainid“ must appear in the GROUP BY clause or be used in an a
- Dbeaver connects hive to solve the problem that hive custom UDF functions cannot be used in SQL queries in dbeaver
- [Solved] ERROR com.alibaba.druid.pool.DruidDataSource – init datasource error, url jdbcmysql
- [Solved] Running in 64 bit mode with the 32 bit Oracle client installed
- ERROR 1054(42S22) Unknown column ‘password’ in ‘field list’ (Fixed)