Spring-boot应用程序无法识别在PostgreSQL DB中所做的更改

时间:2019-05-16 08:39:38

标签: java spring postgresql hibernate spring-boot

我有一个数据库,在其中更改了几列的类型。当我尝试运行应该连接到同一数据库的Spring-boot应用程序时,出现以下错误:

Schema-validation: wrong column type encountered in column [area] in table [hero]; found [polygon (Types#OTHER)], but expecting [bytea (Types#VARBINARY)]

我已经仔细检查了我的表,并且所述列的类型显然是多边形,我不知道为什么要使用其他类型,这是相关文件:

application.properties:

spring.datasource.url=jdbc:postgresql://localhost:5432/herodb
spring.datasource.username=postgres
spring.datasource.password=123
spring.jpa.hibernate.ddl-auto=validate
spring.datasource.driver-class-name=org.postgresql.Driver
spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

英雄实体类:

package com.db.entities;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;
import com.db.DBApp;
import org.hibernate.annotations.Type;
import org.postgresql.geometric.PGpoint;
import org.postgresql.geometric.PGpolygon;

@Entity
@Table(name="hero")
public class Hero
{

    public int getHid() {
        return hid;
    }

    public PGpolygon getArea() {
        return area;
    }

    public String getSpower() {
        return spower;
    }

    public String getFname() {
        return fname;
    }

    public String getLname() {
        return lname;
    }

    public DBApp.PowerCatagory getPc() {
        return pc;
    }

    public float getPower_level() {
        return power_level;
    }

    public float getLuck() {
        return luck;
    }

    public void setHid(int hid) {
        this.hid = hid;
    }

    public void setArea(PGpolygon area) {
        this.area = area;
    }

    public void setSpower(String spower) {
        this.spower = spower;
    }

    public void setFname(String fname) {
        this.fname = fname;
    }

    public void setLname(String lname) {
        this.lname = lname;
    }

    public void setPc(DBApp.PowerCatagory pc) {
        this.pc = pc;
    }

    public void setPower_level(float power_level) {
        this.power_level = power_level;
    }

    public void setLuck(float luck) {
        this.luck = luck;
    }

    @Id private int hid;//This is the table's primary key
    private String fname;
    private String lname;
    private float luck;
    private float power_level;
    private String spower;
    private DBApp.PowerCatagory pc;
    private PGpolygon area;


    public Hero(int hid, String fname, String lname, float luck,float power_level,String spower,DBApp.PowerCatagory pc,PGpolygon area) {
        this.hid = hid;
        this.area = area;
        this.spower = spower;
        this.fname = fname;
        this.lname = lname;
        this.pc = pc;
        this.power_level = power_level;
        this.luck = luck;
    }

    public Hero()
    {

    }

}

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>MyDBExcercise</groupId>
    <artifactId>mydbexxcercise</artifactId>
    <version>1.0-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-parent</artifactId>
        <version>2.1.4.RELEASE</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>com.aerospike</groupId>
            <artifactId>spring-data-aerospike</artifactId>
            <version>2.0.1.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>


    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>


</project>

提前谢谢!

0 个答案:

没有答案