spring boot - 整合jpa
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</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>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.</version>
</dependency>
spring.datasource.url=jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=root
spring.datasource.driverClassName= com.mysql.jdbc.Driver
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
@Entity
@Table(name="t_user")
public class JpaUser {
@Column(name="name")
private String name ;
@Column(name="address")
private String address ;
@Column(name="id")
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id ;
@Column(name="age1")
private Integer age ;
@Column(name="age11")
private Integer age1 ; public JpaUser(String name, String address, Integer age, Integer age1,Integer id) {
this.name = name;
this.address = address;
this.age = age;
this.age1 = age1;
this.id = id;
} public JpaUser() {
}
}
public interface JpaUserRespotory extends JpaRepository<JpaUser,Integer> {
}
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = springBoot.class)
public class JpaTest {
@Autowired
JpaUserRespotory jpaUserRespotory ;
@Test
public void test1 () {
JpaUser jpaUser = new JpaUser("名称","地址",,,);
jpaUserRespotory.save(jpaUser);
}
}
spring boot - 整合jpa的更多相关文章
- spring boot 系列之四:spring boot 整合JPA
上一篇我们讲了spring boot 整合JdbcTemplate来进行数据的持久化, 这篇我们来说下怎么通过spring boot 整合JPA来实现数据的持久化. 一.代码实现 修改pom,引入依赖 ...
- Spring Boot整合JPA、Redis和Swagger2
好久没有总结了,最近也一直在学习.今天就把spring boot与其它技术的整合做个小总结,主要是jpa.redis和swagger2.公司里有用到这些,整合起来也很简单. 首先,新建一个Spring ...
- Spring Boot 整合 JPA 使用多个数据源
介绍 JPA(Java Persistence API)Java 持久化 API,是 Java 持久化的标准规范,Hibernate 是持久化规范的技术实现,而 Spring Data JPA 是在 ...
- Spring Boot2 系列教程(二十五)Spring Boot 整合 Jpa 多数据源
本文是 Spring Boot 整合数据持久化方案的最后一篇,主要和大伙来聊聊 Spring Boot 整合 Jpa 多数据源问题.在 Spring Boot 整合JbdcTemplate 多数据源. ...
- Spring Boot2 系列教程(二十四)Spring Boot 整合 Jpa
Spring Boot 中的数据持久化方案前面给大伙介绍了两种了,一个是 JdbcTemplate,还有一个 MyBatis,JdbcTemplate 配置简单,使用也简单,但是功能也非常有限,MyB ...
- spring boot 整合JPA多数据源
上个文章介绍了spring boot在使用Mybatis持久化技术的时候如何使用多数据源,今天再补充一个使用spring data jpa实现多数据源的使用情况,JPA是一套数据库持久化规范,或者称之 ...
- Spring Boot从入门到精通之:二、Spring Boot整合JPA
springboot-jpa 开发工具 系统: windows10 开发工具: Intellij IDEA 2018.2.6 springboot: 2.0.6.RELEASE jdk: 1.8.0_ ...
- spring boot 整合JPA bean注入失败
有时候报的错误让你匪夷所思,找错误得学会找根.源头在哪里? 比如:我们刚开始看的错误就是 org.springframework.beans.factory.UnsatisfiedDependency ...
- spring boot - 整合jpa多对对关系保存和查询示例
pojo: package com.example.zs.springDataJpa; import org.hibernate.annotations.Proxy; import javax.per ...
随机推荐
- Jenkins Vue项目自动构建以及构建后续操作
Jenkins在linux上的安装教程:http://www.ityouknow.com/springboot/2017/11/11/springboot-jenkins.html 另外,关于在win ...
- c/c++再学习:C与Python相互调用
c/c++再学习:Python调用C函数 Python 调用C函数比较简单 这里两个例子,一个是直接调用参数,另一个是调用结构体 C代码 typedef struct { int i1; int i2 ...
- 学习使人快乐6--XML
一.XML概念 Extensible Markup Language,翻译过来为可扩展标记语言.Xml技术是w3c组织发布的,目前推荐遵循的是W3C组织于2000发布的XML1.0规范. 二.学习XM ...
- Goland2019.1破解
Goland2019.1破解 Goland2019.1:http://www.jetbrains.com/goland/download/ 破解补丁:https://pan.baidu.com/s/1 ...
- flask权限控制
大概思路为通过管理员id的查询角色,然后查看相应权限,为列表类型,然后通过id查询对应的路由规则,进而得出结论得出是否具有该权限 具体代码: def admin_auth(f): @wraps(f) ...
- java int数组任何数之间间隔不能对于指定数,内付极速排序
public static void main(String[] args) { int []arr = {300,310, 210,313,334,360,255,233,275,274,410,5 ...
- IDEA 使用Mybatis效率飞起来的必备工具:MybatisCodeHelperPro 最新破解版,亲测可用!
IDEA 2018.3.5 最新版本亲测可用. Git地址:https://github.com/pengzhile/MyBatisCodeHelper-Pro-Crack/releases 下载最新 ...
- TortoiseGit的ssh key和Git的ssh key
情景模拟: 你使用Git+TortoiseGit对项目进行版本控制,本地库(自己电脑建立的.git)与远程库(如GitLab上建立)通信需要使用ssh验证,你用git生成公钥并保存到了Gitlab上, ...
- 近期待学习&目标内容
算法 Splay 树链剖分 AC自动机 问题 bzoj1010[HNOI2008]玩具装箱 bzoj1096[ZJOI2007]仓库建设 bzoj1597[USACP2008 Mar]土地购买 bzo ...
- SharePoint2016: 使用powerShell启用project web app
1. 创建pwa承载的webApplication 在SharePoint2016管理中心>应用程序管理>管理web应用程序,新建web应用程序>sharepoint-1001, ...