Spring Data Repository的核心接口是Repository(好像也没什么好惊讶的)。这个接口需要领域类(Domain Class)跟领域类的ID类型作为参数。这个接口主要是让你能知道继承这个类的接口的类型。CrudRepository 供了对被管理的实体类的一些常用CRUD方法。


2. springboot 整合spring data jpa

默认你已经构建好了spring boot 项目,关于spring boot项目的新建,请参考: 
springboot Demo 
springboot 整合mybatis

2.1. 首先导入jar 包

springboot 整合spring data jpa 首先要导入依赖的jar包。pom.xml 文件中新增如下依赖:

  1. <!-- spring-data-jpa -->
  2. <dependency>
  3. <groupId>org.springframework.data</groupId>
  4. <artifactId>spring-data-jpa</artifactId>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.hibernate</groupId>
  8. <artifactId>hibernate-entitymanager</artifactId>
  9. </dependency>
  10. <dependency>
  11. <groupId>org.aspectj</groupId>
  12. <artifactId>aspectjweaver</artifactId>
  13. </dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.21</version>
</dependency>

  1. <!--data source spring data jpa 需要用c3p0 连接池-->
  2. <dependency>
  3. <groupId>com.mchange</groupId>
  4. <artifactId>c3p0</artifactId>
  5. <version>0.9.5.2</version>
  6. <exclusions>
  7. <exclusion>
  8. <groupId>commons-logging</groupId>
  9. <artifactId>commons-logging</artifactId>
  10. </exclusion>
  11. </exclusions>
  12. </dependency>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

2.2 配置datasource

新建DBConfig.Java 文件 配置数据源。

  1. package com.example.config;
  2. import java.beans.PropertyVetoException;
  3. import org.springframework.beans.factory.annotation.Autowired;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. import org.springframework.core.env.Environment;
  7. import com.mchange.v2.c3p0.ComboPooledDataSource;
  8. @Configuration
  9. public class DBConfig {
  10. @Autowired
  11. private Environment env;
  12. @Bean(name="dataSource")
  13. public ComboPooledDataSource dataSource() throws PropertyVetoException {
  14. ComboPooledDataSource dataSource = new ComboPooledDataSource();
  15. dataSource.setDriverClass(env.getProperty("ms.db.driverClassName"));
  16. dataSource.setJdbcUrl(env.getProperty("ms.db.url"));
  17. dataSource.setUser(env.getProperty("ms.db.username"));
  18. dataSource.setPassword(env.getProperty("ms.db.password"));
  19. dataSource.setMaxPoolSize(20);
  20. dataSource.setMinPoolSize(5);
  21. dataSource.setInitialPoolSize(10);
  22. dataSource.setMaxIdleTime(300);
  23. dataSource.setAcquireIncrement(5);
  24. dataSource.setIdleConnectionTestPeriod(60);
  25. return dataSource;
  26. }
  27. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35

2.3. 添加数据库连接信息

在配置文件application.properties中添加数据库连接信息如下:

  1. ms.db.driverClassName=com.mysql.jdbc.Driver
  2. ms.db.url=jdbc:mysql://localhost:3306/msm?prepStmtCacheSize=517&cachePrepStmts=true&autoReconnect=true&characterEncoding=utf-8&allowMultiQueries=true
  3. ms.db.username=root
  4. ms.db.password=admin
  5. ms.db.maxActive=500
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

2.4 配置JpaConfig

新建JpaConfig.java 文件内容如下:

  1. package com.example.config;
  2. import java.util.HashMap;
  3. import java.util.Map;
  4. import javax.persistence.EntityManagerFactory;
  5. import javax.sql.DataSource;
  6. import org.springframework.beans.factory.annotation.Autowired;
  7. import org.springframework.context.annotation.Bean;
  8. import org.springframework.context.annotation.Configuration;
  9. import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
  10. import org.springframework.orm.jpa.JpaTransactionManager;
  11. import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
  12. import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
  13. import org.springframework.transaction.PlatformTransactionManager;
  14. import org.springframework.transaction.annotation.EnableTransactionManagement;
  15. @Configuration
  16. //此处是你dao文件所在的包名
  17. @EnableJpaRepositories("com.example.*.dao")
  18. @EnableTransactionManagement
  19. public class JpaConfig {
  20. @Autowired
  21. private DataSource dataSource;
  22. @Bean
  23. public EntityManagerFactory entityManagerFactory() {
  24. HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
  25. LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();
  26. factory.setJpaVendorAdapter(vendorAdapter);
  27. //此处com.example.*.model是你的java bean所在的包名
  28. factory.setPackagesToScan("com.example.*.model");
  29. factory.setDataSource(dataSource);
  30. Map<String, Object> jpaProperties = new HashMap<String, Object>();
  31. jpaProperties.put("hibernate.ejb.naming_strategy","org.hibernate.cfg.ImprovedNamingStrategy");
  32. jpaProperties.put("hibernate.jdbc.batch_size",50);
  33. factory.setJpaPropertyMap(jpaProperties);
  34. factory.afterPropertiesSet();
  35. return factory.getObject();
  36. }
  37. @Bean
  38. public PlatformTransactionManager transactionManager() {
  39. JpaTransactionManager txManager = new JpaTransactionManager();
  40. txManager.setEntityManagerFactory(entityManagerFactory());
  41. return txManager;
  42. }
  43. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55

2.5 新建对应数据库表的实体类。(也就是java bean )

  1. 注意
  2. @Entity
  3. @Table(name = "sec_user")
  4. 标签的使用,@Entity表示这个是一个实体类,@Table(name = "sec_user") sec_user 是数据库中对应的表名
  5. @Id
  6. @GeneratedValue 对应ID
  7. @Column(name = "name") 对应数据库中该列对应的列名,也就是属性名
  1. package com.example.base.model;
  2. import java.util.Date;
  3. import javax.persistence.Column;
  4. import javax.persistence.Entity;
  5. import javax.persistence.GeneratedValue;
  6. import javax.persistence.Id;
  7. import javax.persistence.Table;
  8. import com.fasterxml.jackson.annotation.JsonIgnore;
  9. @Entity
  10. @Table(name = "sec_user")
  11. public class User {
  12. @Id
  13. @GeneratedValue(strategy=GenerationType.IDENTITY)
  14. private Integer id;
  15. @Column(name = "name")
  16. private String name;
  17. @Column(name = "password")
  18. private String password;
  19. @Column(name = "username")
  20. private String username;
  21. @Column(name = "division_id")
  22. private Integer divisionId;
  23. @Column(name = "email")
  24. private String email;
  25. @Column(name = "gender")
  26. private String gender;
  27. @Column(name = "mobilephone")
  28. private String mobilephone;
  29. @Column(name = "telephone")
  30. private String telephone;
  31. @Column(name = "user_type")
  32. private Integer userType;
  33. @Column(name = "create_by")
  34. private String createBy;
  35. @Column(name = "create_time")
  36. private Date createTime;
  37. @Column(name = "update_by")
  38. private String updateBy;
  39. @Column(name = "update_time")
  40. private Date updateTime;
  41. @Column(name = "disabled")
  42. private Integer disabled;
  43. @Column(name = "theme")
  44. private String theme;
  45. @Column(name = "is_ldap")
  46. private Integer isLdap;
  47. public String getName() {
  48. return name;
  49. }
  50. public void setName(String name) {
  51. this.name = name;
  52. }
  53. @JsonIgnore
  54. public String getPassword() {
  55. return password;
  56. }
  57. public void setPassword(String password) {
  58. this.password = password;
  59. }
  60. public String getUsername() {
  61. return username;
  62. }
  63. public void setUsername(String username) {
  64. this.username = username;
  65. }
  66. public Integer getDivisionId() {
  67. return divisionId;
  68. }
  69. public void setDivisionId(Integer divisionId) {
  70. this.divisionId = divisionId;
  71. }
  72. public String getEmail() {
  73. return email;
  74. }
  75. public void setEmail(String email) {
  76. this.email = email;
  77. }
  78. public String getGender() {
  79. return gender;
  80. }
  81. public void setGender(String gender) {
  82. this.gender = gender;
  83. }
  84. public String getMobilephone() {
  85. return mobilephone;
  86. }
  87. public void setMobilephone(String mobilephone) {
  88. this.mobilephone = mobilephone;
  89. }
  90. public String getTelephone() {
  91. return telephone;
  92. }
  93. public void setTelephone(String telephone) {
  94. this.telephone = telephone;
  95. }
  96. public Integer getUserType() {
  97. return userType;
  98. }
  99. public void setUserType(Integer userType) {
  100. this.userType = userType;
  101. }
  102. public String getCreateBy() {
  103. return createBy;
  104. }
  105. public void setCreateBy(String createBy) {
  106. this.createBy = createBy;
  107. }
  108. public Date getCreateTime() {
  109. return createTime;
  110. }
  111. public void setCreateTime(Date createTime) {
  112. this.createTime = createTime;
  113. }
  114. public String getUpdateBy() {
  115. return updateBy;
  116. }
  117. public void setUpdateBy(String updateBy) {
  118. this.updateBy = updateBy;
  119. }
  120. public Date getUpdateTime() {
  121. return updateTime;
  122. }
  123. public void setUpdateTime(Date updateTime) {
  124. this.updateTime = updateTime;
  125. }
  126. public Integer getDisabled() {
  127. return disabled;
  128. }
  129. public void setDisabled(Integer disabled) {
  130. this.disabled = disabled;
  131. }
  132. public String getTheme() {
  133. return theme;
  134. }
  135. public void setTheme(String theme) {
  136. this.theme = theme;
  137. }
  138. public Integer getIsLdap() {
  139. return isLdap;
  140. }
  141. public void setIsLdap(Integer isLdap) {
  142. this.isLdap = isLdap;
  143. }
  144. public Integer getId() {
  145. return id;
  146. }
  147. public void setId(Integer id) {
  148. this.id = id;
  149. }
  150. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184
  • 185
  • 186
  • 187
  • 188

2.5 编写spring data jpa 的dao层(重头戏哦)

首先我们先了解一下 spring data jpa 的命名规范,然后再开始编写一个简单的测试例子。 



例子: 
新建UserJpaDao类继承 JpaRepository

  1. package com.example.base.dao;
  2. import org.springframework.data.jpa.repository.JpaRepository;
  3. import org.springframework.data.jpa.repository.Query;
  4. import org.springframework.data.repository.query.Param;
  5. import com.example.base.model.User;
  6. /**
  7. * The Interface UserJpaDao.
  8. * @author abel
  9. */
  10. public interface UserJpaDao extends JpaRepository<User, Long> {
  11. /**
  12. * Find by name.
  13. *
  14. * @param name the name
  15. * @return the user
  16. */
  17. User findByName(String name);
  18. /**
  19. * Find by name and user name.
  20. * 如果参数名为多个字母组成,请首字母大写。勿使用驼峰命名,jpa不识别驼峰
  21. * @param name the name
  22. * @param age the age
  23. * @return the user
  24. */
  25. User findByNameAndAge(String name, Integer age);
  26. /**
  27. * Find user.
  28. * User为@Entity 的名字
  29. * @param name the name
  30. * @return the user
  31. */
  32. @Query("from User u where u.name=:name")
  33. User findUser(@Param("name") String name);
  34. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41

2.6 service 层的编写(这一步和Spring mvc 已经没有什么差别的了。)

service 代码如下。(此处我就仅仅写了dao的一个方法)

  1. package com.example.base.service;
  2. import com.example.base.model.User;
  3. /**
  4. * The Interface UserService.
  5. */
  6. public interface UserService {
  7. /**
  8. * Gets the user by name.
  9. *
  10. * @param username the user name
  11. * @return the user by name
  12. */
  13. public User getUserByName(String username);
  14. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

实现如下:

  1. package com.example.base.service.Impl;
  2. import org.springframework.beans.factory.annotation.Autowired;
  3. import org.springframework.stereotype.Service;
  4. import com.example.base.dao.UserJpaDao;
  5. import com.example.base.model.User;
  6. import com.example.base.service.UserService;
  7. /**
  8. *
  9. * @ClassName UserServiceImpl
  10. * @author abel
  11. * @date 2016年11月10日
  12. */
  13. @Service
  14. public class UserServiceImpl implements UserService {
  15. @Autowired
  16. private UserJpaDao userJpaDao;
  17. /**
  18. *
  19. * @param UserName
  20. * @return
  21. */
  22. @Override
  23. public User getUserByName(String username) {
  24. return userJpaDao.findByName(username);
  25. }
  26. }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29

2.7 controller 编写

  1. package com.example.base.controller;
  2. import javax.servlet.http.HttpServletRequest;
  3. import java.util.Map;
  4. import org.springframework.beans.factory.annotation.Autowired;
  5. import org.springframework.http.HttpStatus;
  6. import org.springframework.http.ResponseEntity;
  7. import org.springframework.stereotype.Controller;
  8. import org.springframework.web.bind.annotation.RequestMapping;
  9. import org.springframework.web.bind.annotation.RequestMethod;
  10. import org.springframework.web.bind.annotation.ResponseBody;
  11. import com.example.base.service.UserService;
  12. import com.example.base.util.CommonUtil;
  13. /**
  14. *
  15. * @ClassName UserController
  16. * @author abel
  17. * @date 2016年11月10日
  18. */
  19. @Controller
  20. @RequestMapping(value = "/users")
  21. public class UserController {
  22. @Autowired
  23. private UserService userService;
  24. /**
  25. * 通过spring data jpa 调用方法 api :localhost:8099/users/byname?username=xxx
  26. *
  27. * @param request
  28. * @return
  29. */
  30. @RequestMapping(value = "/byname", method = RequestMethod.GET)
  31. @ResponseBody
  32. public ResponseEntity<Object> getUser(HttpServletRequest request) {
  33. Map<String, Object> map = CommonUtil.getParameterMap(request);
  34. String username = (String) map.get("username");
  35. return new ResponseEntity<>(userService.getUserByName(username), HttpStatus.OK);
  36. }
  37. }

spring boot + spring data jpa的更多相关文章

  1. 初识在Spring Boot中使用JPA

    前面关于Spring Boot的文章已经介绍了很多了,但是一直都没有涉及到数据库的操作问题,数据库操作当然也是我们在开发中无法回避的问题,那么今天我们就来看看Spring Boot给我们提供了哪些疯狂 ...

  2. 【实验一 】Spring Boot 集成 hibernate & JPA

    转眼间,2018年的十二分之一都快过完了,忙于各类事情,博客也都快一个月没更新了.今天我们继续来学习Springboot对象持久化. 首先JPA是Java持久化API,定义了一系列对象持久化的标准,而 ...

  3. 使用spring boot中的JPA操作数据库

    前言 Spring boot中的JPA 使用的同学都会感觉到他的强大,简直就是神器一般,通俗的说,根本不需要你写sql,这就帮你节省了很多时间,那么下面我们来一起来体验下这款神器吧. 一.在pom中添 ...

  4. 基于Spring Boot,使用JPA动态调用Sql查询数据

    在<基于Spring Boot,使用JPA操作Sql Server数据库完成CRUD>,<基于Spring Boot,使用JPA调用Sql Server数据库的存储过程并返回记录集合 ...

  5. 基于Spring Boot,使用JPA调用Sql Server数据库的存储过程并返回记录集合

    在上一篇<基于Spring Boot,使用JPA操作Sql Server数据库完成CRUD>中完成了使用JPA对实体数据的CRUD操作. 那么,有些情况,会把一些查询语句写在存储过程中,由 ...

  6. Spring Boot + Spring Data + Elasticsearch实例

    Spring Boot + Spring Data + Elasticsearch实例 学习了:https://blog.csdn.net/huangshulang1234/article/detai ...

  7. 255.Spring Boot+Spring Security:使用md5加密

    说明 (1)JDK版本:1.8 (2)Spring Boot 2.0.6 (3)Spring Security 5.0.9 (4)Spring Data JPA 2.0.11.RELEASE (5)h ...

  8. 256.Spring Boot+Spring Security: MD5是加密算法吗?

    说明 (1)JDK版本:1.8 (2)Spring Boot 2.0.6 (3)Spring Security 5.0.9 (4)Spring Data JPA 2.0.11.RELEASE (5)h ...

  9. Spring Boot+Spring Security:获取用户信息和session并发控制

    说明 (1)JDK版本:1.8(2)Spring Boot 2.0.6(3)Spring Security 5.0.9(4)Spring Data JPA 2.0.11.RELEASE(5)hiber ...

  10. Spring Boot/Spring Cloud

    104.什么是 spring boot?         在Spring框架这个大家族中,产生了很多衍生框架,比如 Spring.SpringMvc框架等,Spring的核心内容在于控制反转(IOC) ...

随机推荐

  1. 如何解决outlook2013邮件规则for other machine的失效问题

    如何解决outlook2013邮件规则for other machine的失效问题 问题描述:因为重装系统,outlook2013进去后->Rules and Alerts->发现所有原来 ...

  2. 自己实现的vector

    #include <iostream> #include <memory> using std::cout; using std::endl; using std::alloc ...

  3. Mysql源码学习——源码目录结构

    目录清单 目录名 注释 Bdb 伯克利DB表引擎 BUILD 构建工程的脚本 Client 客户端 Cmd-line-utils 命令行工具 Config 构建工程所需的一些文件 Dbug Fred ...

  4. 洛谷P1352——动规

    题目:https://www.luogu.org/problemnew/show/P1352 代码如下: #include<iostream> #include<cstdio> ...

  5. CentOS虚拟机通过主机WIFI上网

    0 环境简介 环境如下: (1)宿主机为WIN7系统,连接内网,同时通过本机的WIFI上外网: (2)虚拟机为VMWare12下的CentOS7系统. 1 虚拟机设置 选择NAT 模式: 2 宿主机W ...

  6. Sharding & IDs at Instagram, Flickr ID generation

    Instagram: http://instagram-engineering.tumblr.com/post/10853187575/sharding-ids-at-instagram Flickr ...

  7. unity3d 自定义载入条/载入动画

    在 Assets 下新建文件夹 WebGLTemplates , 在 WebGLTemplates 文件夹下新建文件夹 MyTemplate, 新建index. 在 PlayerSetting 中的 ...

  8. java中的 break continue return作用详解

    break: 此语句导致程序终止包含它的循环,并进行程序的下一阶段(整个循环后面的语句),即,不是跳到下一个循环周期而是退出循环.如果break语句包含在嵌套循环里,它只跳出最里面的循环. 如下代码: ...

  9. Android实现监听控件点击事件

    Android实现监听控件点击事件 引言 这篇文章主要想写一下Android实现监听点击事件的几种方法,Activity和Fragment实现起来有些方法上会有些不同,这里也略做介绍. 最近一直在忙一 ...

  10. Python序列化模块pickle和json使用和区别

    这是用于序列化的两个模块: • json: 用于字符串和python数据类型间进行转换 • pickle: 用于python特有的类型和python的数据类型间进行转换 Json模块提供了四个功能:d ...