当前位置: 首页 > 知识库问答 >
问题:

无法使用postgres DB确定数据库类型NONE的嵌入式数据库驱动程序类

罗诚
2023-03-14

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;

}
@Entity
@Table(name = "WORKORDER")
public class WorkOrder {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;
    private String workOrder;
}
<?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>

如果您想要一个嵌入式数据库,请在类路径上放置一个受支持的数据库。如果要从特定配置文件加载数据库设置,则可能需要激活它(当前没有配置文件处于活动状态)。

共有1个答案

钮誉
2023-03-14

spring看不到application.properties(以及corse no embedded db集)时,将出现此消息,以验证:确保使用的端口是9093,而不是默认的8080。

 类似资料: