我试图运行由其他人制作的弹簧引导应用程序。我试图将我的本地数据库附加到应用程序,但是当我运行它时,它会给出以下错误;Spring引导Bean异常:无法确定数据库类型为NONE的嵌入式数据库驱动程序类
org.springframework.beans.factory.BeanCreationException:错误创建名为 'org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration' 豆:自动装配依赖注入失败;嵌套异常是org.springframework.beans.factory.BeanCreationException:无法自动装入字段:private javax.sql.DataSource org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration.dataSource;嵌套异常是org.springframework.beans.factory.BeanCreationException:在类路径资源[org/springframework/boot/autoconfigure/jdbc/DataSourceAutoConfiguration $ NonEmbeddedConfiguration.class]中定义名称为'dataSource'的bean时出错:通过工厂方法的Bean实例化失败;嵌套异常是org.springframework.beans.BeanInstantiationException:无法实例化[javax.sql.DataSource]:工厂方法'dataSource'抛出异常;嵌套异常是org.springframework.boot.autoconfigure.jdbc.DataSourceProperties $ DataSourceBeanCreationException:无法确定数据库类型为NONE的嵌入式数据库驱动程序类。如果你想要一个嵌入式数据库,请在类路径中放一个支持的数据库。如果您要从特定配置文件加载数据库设置,则可能需要激活它(没有配置文件当前处于活动状态)。
我是新来的,我找不出什么问题。一些细节:
其中xxx =数据库的名称。
工作台:
Name: Local instance wampmysqld64
Host: localhost
Port: 3306
Server: MySQL Community Server (GPL)
Version: 5.7.18-log
Connector: C++ 1.1.4
Login User: root
Current User: [email protected]
SSL: Disabled
且服务器启动和运行。
EDIT
的pom.xml
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>****</groupId>
<artifactId>****</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.3.6.RELEASE</version>
</parent>
<dependencies>
<dependency>
<groupId>org.modelmapper</groupId>
<artifactId>modelmapper</artifactId>
<version>1.1.0</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-rest</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
EDIT2
Application.properties
spring.datasource.url=jdbc:mysql://localhost:3306/xxx
spring.datasource.username=root
spring.datasource.password=root
spring.jpa.hibernate.ddl-auto=update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
spring.jpa.properties.hibernate.id.new_generator_mappings = false
spring.jpa.properties.hibernate.format_sql = true
logging.level.org.hibernate.SQL=DEBUG
logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE
ng.level.org.hibernate.type.descriptor.sql.BasicBinder = TRACE
Application.java
package gdprserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.web.SpringBootServletInitializer;
import org.springframework.context.annotation.Bean;
@SpringBootApplication(exclude = RepositoryRestMvcAutoConfiguration.class)
public class Application extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(final SpringApplicationBuilder application) {
return application.sources(Application.class);
}
public static void main(final String[] args) {
SpringApplication.run(Application.class, args);
}
@Bean
public ModelMapper modelMapper() {
return new ModelMapper();
}
}
EDIT3
我运行与Spring应用程序启动CMD使用命令:java -jar xxx.jar
你确定你的'类路径(理想情况下'的src/main/resources' application.properties'文件?同时显示你的'@ SpringBootApplication'类 –
的application.properties位于'的src/main /资源'是的。 – Klyner
没有spring-boot-starter-jdbc或者spring-boot-starter-data-jpa? –