鍍金池/ 問答/Java  數(shù)據(jù)庫  HTML/ jpa無法自動(dòng)創(chuàng)建數(shù)據(jù)庫表

jpa無法自動(dòng)創(chuàng)建數(shù)據(jù)庫表

下面是配置信息:

spring.jpa:
    show-sql: true
    database: MYSQL
    properties.hibernate.dialect: org.hibernate.dialect.MySQL5Dialect
    hibernate:
      ddl-auto: update
      naming-strategy: org.hibernate.cfg.ImprovedNamingStrategy

spring.datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://192.168.1.115/ssm?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=utf8&useSSL=false&autoReconnect=true&serverTimezone=CTT
    username: admin
    password: 123456
    initial-size: 10
    max-wait: 10000
    maximum-pool-size: 100
    max-active: 100
    max-idle: 10
    minIdle: 2
    test-on-borrow: false
    test-on-return: true
    test-while-idle: true
    validation-query: select 1

下面是實(shí)體類:

@Entity
@Table(name = "ssm_icon")
public class Icon {
    /**
     * 主鍵id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id")
    private Long id;
    /**
     * 圖標(biāo)名稱
     */
    @Column(name = "icon_name")
    private String iconName;
    /**
     * 圖標(biāo)地址
     */
    @Column(name = "icon_address")
    private String iconAddress;
    /**
     * 圖標(biāo)編碼
     */
    @Column(name = "icon_code")
    private String iconCode;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getIconName() {
        return iconName;
    }

    public void setIconName(String iconName) {
        this.iconName = iconName;
    }

    public String getIconAddress() {
        return iconAddress;
    }

    public void setIconAddress(String iconAddress) {
        this.iconAddress = iconAddress;
    }

    public String getIconCode() {
        return iconCode;
    }

    public void setIconCode(String iconCode) {
        this.iconCode = iconCode;
    }
}

今天新建的一個(gè)srping boot項(xiàng)目無法jpa無法自動(dòng)生成數(shù)據(jù)庫表,把ddl-auto 換成create也不行,哪位大神可以幫忙看看是什么原因嗎

回答
編輯回答
菊外人

問題解決了,最后發(fā)現(xiàn)是mysql的多版本,調(diào)用公司自身服務(wù)接口的時(shí)候配了一個(gè)5.1.41的版本,項(xiàng)目本身又配了一個(gè)5.1.38的版本,后來把項(xiàng)目里的版本注釋掉刷新一下就解決了

2017年7月17日 03:19