我收到错误"无法确定数据库类型为NONE"的嵌入式数据库驱动程序类。在eclipse中运行spring boot应用程序时。 我在网上搜索但找不到任何有用的东西。请参阅以下代码: -
Application.properties
server.port=9093
spring.datasource.url=jdbc:postgresql://localhost:5432/DB
spring.datasource.username=postgres
spring.datasource.password=Sunny@310591
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
logging.level.org.springframework.web=INFO
logging.level.com.ge.punemmf.qualityputaway=DEBUG
logging.level.org.hibernate=ERROR
logging.file=logs/spring-boot-logging.log
spring.database.driverClassName=org.postgresql.Driver
endpoints.sensitive=false
Application.java
@SpringBootApplication
@EntityScan(basePackageClasses = { CenterOfExcellence.class, WorkOrder.class })
public class WarehouseVisibilityApplication {
public static void main(String[] args) {
SpringApplication.run(WarehouseVisibilityApplication.class, args);
}
}
CenterOfExcellence.java
@Entity
@Table(name = "CENTEROFEXCELLENCE")
public class CenterOfExcellence {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private int id;
private String name;
@OneToMany
@JoinTable(name = "CENTEROFEXCELLENCE_WORKORDER",
joinColumns = @JoinColumn(name = "center_of_excellence_id"), inverseJoinColumns = @JoinColumn(name = "workorder_id"))
private Set<WorkOrder> workorders;
}
WorkOrder.java
@Entity
@Table(name = "WORKORDER")
public class WorkOrder {
@Id
@GeneratedValue(strategy=GenerationType.IDENTITY)
private int id;
private String workOrder;
}
的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.warehousevisibility</groupId>
<artifactId>WarehouseVisibility</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>WarehouseVisibility</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
错误: -
说明
无法确定数据库类型为NONE的嵌入式数据库驱动程序类
动作:
如果您需要嵌入式数据库,请在类路径中放置一个受支持的数据库。如果要从特定配置文件加载数据库设置,则可能需要激活它(当前没有配置文件处于活动状态)。
答案 0 :(得分:0)
当spring无法看到application.properties时(和corse没有嵌入式数据库集),会出现此消息 要验证:确保所使用的端口是9093而不是默认值8080。