@Entity
public class Country {
//实体类参考本人博客地址:https://blog.youkuaiyun.com/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)
springboot集成jpa访问数据库
最新推荐文章于 2025-06-05 14:13:31 发布