Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 实体类未使用jpa在mySql数据库中创建表_Java_Hibernate_Api_Spring Data Jpa_Mysql Workbench - Fatal编程技术网

Java 实体类未使用jpa在mySql数据库中创建表

Java 实体类未使用jpa在mySql数据库中创建表,java,hibernate,api,spring-data-jpa,mysql-workbench,Java,Hibernate,Api,Spring Data Jpa,Mysql Workbench,虽然我可以在其他项目中创建表,但此项目不是从实体类创建表。我在使用eclipse的spring boot jpa中有以下实体类: package com.abc.allcoaches.entity; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; impor

虽然我可以在其他项目中创建表,但此项目不是从实体类创建表。我在使用eclipse的spring boot jpa中有以下实体类:

package com.abc.allcoaches.entity;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;


@Entity
@Table(name = "Coaches_TBL")

public class Coaches {
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    private int id;
    private String t;
    private String c;
    
    
    
    public Coaches() {
        
    }
    
    public Coaches(int id, String team, String coach ) {
        
        super();
        this.id = id;
        this.t = team;
        this.c = coach;
        
    
    }

    public int getId() {
        return id;
    }

    public void setID(int id) {
        this.id = id;
    }

    public String getT() {
        return t;
    }

    public void setT(String t) {
        this.t = t;
    }

    public String getC() {
        return c;
    }

    public void setC(String c) {
        this.c = c;
    }

    
    
}


存储库类如下所示:

package com.abc.allcoaches.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import com.abc.allcoaches.entity.Coaches;


public interface CoachesRepository extends JpaRepository<Coaches, Integer> {

    Coaches findByTeam(String team);
    
}


但是在没有任何错误地运行项目之后,我没有看到在mySql工作台中创建的表。我试了好几次都没有成功。如果你能找到解决办法,请告诉我。干杯

我发现了导致无法创建表的问题。我的应用程序类(带有main(String[]args)方法)位于不同的包中。我重构了软件包,问题解决了。

这是否回答了您的问题@samabcde不是真的。我拥有的属性文件配置适用于除此项目之外的所有其他项目。
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://localhost:3306/football2020db
spring.datasource.username = root
spring.datasource.password = password
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect