1. 程式人生 > >springboot整合jpa訪問資料庫

springboot整合jpa訪問資料庫


@Entity
public class Country {
    //實體類參考本人部落格地址:https://blog.csdn.net/yl_hahha/article/details/80208161
    @Id
    @GeneratedValue
    private long id;
    private String countryname;
    private String countrycode;
    public long getId() {
        return id;
    }
    public void setId(long id) {
        this
.id = id; } public String getCountryname() { return countryname; } public void setCountryname(String countryname) { this.countryname = countryname; } public String getCountrycode() { return countrycode; } public void setCountrycode(String countrycode) { this
.countrycode = countrycode; } @Override public String toString() { return "Country [id=" + id + ", countryname=" + countryname + ", countrycode=" + countrycode + "]"; } } public interface CountryDao extends JpaRepository<Country,Long>{ } @SpringBootApplication public
class DemoApplication { /** * Failed to determine a suitable driver class * 說明你沒有配置資料來源 或者資原始檔不認識yum檔案 * @param args */ public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } } [專案地址](https://github.com/ylha/springboot-web1)