Code: Select all
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
Property: driverclassname
Value: com.mysql.jdbc.Driver;
Origin: "driverClassName" from property source "source"
Reason: Failed to load driver class com.mysql.jdbc.Driver; in either of HikariConfig class loader or Thread context classloader
Action:
Update your application's configuration
< /code>
Ich habe versucht, .m2, Neuträglichkeit, Maven sauber, kompilieren, zu installieren, und die meisten Dinge, die ich im Internet finden konnte, ohne Erfolg. Das Lustige ist, dass ich nur ein anderes Projekt mit der MySQL-Datenbank habe. Ich hatte ein ähnliches Problem, aber das Hinzufügen von [b] Mysql-Connector-Java [/b] Abhängigkeit hat es gelöst. Ich habe momentan keine Ahnung.spring.profiles.active=@profilename@
#H2 in memory database
domain.datasource.type=H2
domain.datasource.url=jdbc:h2:mem:store;MODE=MYSQL;
domain.datasource.driver-class=org.h2.Driver
domain.datasource.username=sa
domain.datasource.password=
domain.datasource.generate-dll=true
Code: Select all
spring.profiles.active=@profilename@
#MySQL local database
domain.datasource.type=MYSQL
domain.datasource.url=jdbc:mysql://localhost:3600/store;
domain.datasource.driver-class=com.mysql.jdbc.Driver;
domain.datasource.username=store
domain.datasource.password=store
domain.datasource.generate-dll=false
Code: Select all
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
sk.personal
my-project
0.0.1-SNAPSHOT
jar
my-project
My personal project.
org.springframework.boot
spring-boot-starter-parent
2.0.5.RELEASE
UTF-8
UTF-8
1.8
org.springframework.boot
spring-boot-starter
2.0.5.RELEASE
org.springframework.boot
spring-boot-starter-data-jpa
org.springframework.boot
spring-boot-starter-web
com.h2database
h2
runtime
org.projectlombok
lombok
true
org.springframework.boot
spring-boot-starter-test
test
org.springframework.security
spring-security-test
test
mysql
mysql-connector-java
runtime
local_h2
local_h2
true
local_mysql
local_mysql
true
org.springframework.boot
spring-boot-maven-plugin
Code: Select all
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;
import javax.sql.DataSource;
@Configuration
public class DatasourceConfig {
@Value("${domain.datasource.url}")
private String url;
@Value("${domain.datasource.username}")
private String username;
@Value("${domain.datasource.password}")
private String password;
@Value("${domain.datasource.type}")
private String type;
@Value("${domain.datasource.driver-class}")
private String driverClass;
@Bean
public DataSource dataSource() {
if (type.equals("MYSQL")) {
return DataSourceBuilder
.create()
.username(username)
.password(password)
.url(url)
.driverClassName(driverClass)
.build();
} else {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
return builder
.setType(EmbeddedDatabaseType.H2)
.build();
}
}
}