当前位置:首页 > Java技术 > SpringBoot整合hibernate纯注解版

SpringBoot整合hibernate纯注解版

2022年05月15日 21:58:07Java技术454

一、hibernate是什么

hibernate是一款优秀的ORM(Object Relational Mapping ,对象关系映射)框架,是一种面向对象编程的框架,它对JDBC进行了封装,是一个全自动的ORM框架,可以自动生成SQL语句,也可以自定义HQL进行执行脚本。

优点:hibernate在进行对象进行数据库存储时,可以不进行SQL编写,配置好对象与数据库的关系后,自动生成SQL执行,也可自动创建表,在简单的数据库关系项目中,可进行高效率的工作。

缺点:hibernte在项目开发的过程中,由于全自动生成SQL,在使用时会发现,当执行复杂关系的数据库关系的业务时,hibernate略显笨重,执行时间偏长且无法灵活的配置关系较为复杂的业务,所以后期有了mybatis的出现,为了可以更加便捷的写sql,灵活的配置SQL。

二、为什么我还要使用hibernate

刚才也描述了,在进行关系较为简单的项目业务上,hibernate可以自动生成SQL执行,也提供了增删改查的方法,可以很简单直接进行对象存储删除,所以在开发逻辑简单的业务时(例如帮学妹做个毕设,课程设计什么的,你懂的,哈哈),可以利用hibernate进行快速的项目开发。

三、开始整合

1.搭建SpringBoot工程,此处不再多讲,之前已经讲过,可以翻看SpringBoot的搭建的帖子,(点我跳转),在pom文件加上如下依赖

1
2
3
4
5
6
7
8
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>

2.在java文件夹下创建自定义包,项目结构如下

SpringBoot整合hibernate纯注解版 _ JavaClub全栈架构师技术笔记

3.全局配置文件如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#配置数据源
spring.datasource.url=jdbc:mysql://localhost:3306/yang
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
#服务启动信息
server.port=8088
#jpa配置
#数据库类型为mysql
spring.jpa.database = MYSQL
#是否显示sql
spring.jpa.show-sql = true
#自动创建表
spring.jpa.hibernate.ddl-auto = update
#创建命名策略
spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy
#数据库方言为mysql
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

4.创建实体类-用户类,及统一返回对象ResultObject

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
package com.yang.bean;

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

/**
* 用户实体类
* @author Yang
*
*/
@Entity
@Table(name="t_user")
public class User {
/*用户名称*/
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@Column(name="user_id")
private int userId;
/*用户登录名称*/
@Column(name="user_name")
private String userName;
/* 用户登录密码 */
@Column(name="pass_word")
private String password;
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
@Override
public String toString() {
return "User [userId=" + userId + ", userName=" + userName + ", password=" + password + "]";
}
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
package com.yang.bean;

public class ResultObject<T> {
private int code;
private String msg;
private T data;
private Long count;

public Long getCount() {
return count;
}
public void setCount(Long count) {
this.count = count;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}

5.创建数据查询接口,需要继承JpaRepository接口来实现查询

1
2
3
4
5
6
7
8
9
10
package com.yang.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.yang.bean.User;

@Repository
public interface UserDao extends JpaRepository<User, Long>{

}

6.编写Service接口及实现类,实现类注入数据层接口

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package com.yang.service;

import java.util.List;

import com.yang.bean.User;

/**
*
* @author yzx96
*
*/
public interface UserService {
/**
* 查询所有用户
* @return
*/
public List<User> getAllUser();
}
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
package com.yang.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.yang.bean.User;
import com.yang.dao.UserDao;
import com.yang.service.UserService;

/**
* 服务实现
* @author yzx96
*
*/
@Service
public class UserServiceImpl implements UserService {
/**
* 注入数据层接口
*/
@Autowired
UserDao userDao;

@Override
public List<User> getAllUser() {
return userDao.findAll();
}

}

7.编写控制器

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
package com.yang.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yang.bean.ResultObject;
import com.yang.bean.User;
import com.yang.service.UserService;
@RestController
@RequestMapping("/user")
public class UseController {

@Autowired
private UserService userService;


@RequestMapping("/getAllUser")
public ResultObject<List<User>> getAllUser(){
List<User> list=userService.getAllUser();
ResultObject<List<User>> rs=new ResultObject<List<User>>();
rs.setCode(0);
rs.setData(list);
return rs;
}
}

8.编写启动类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.yang.boot;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;

@ComponentScan(basePackages={"com.yang"}) // 扫描该包路径下的所有spring组件
@EnableJpaRepositories("com.yang.dao") // JPA扫描该包路径下的Repositorie
@EntityScan("com.yang.bean")
@SpringBootApplication
public class StartAppHibernatelication {
public static void main(String[] args) {
SpringApplication.run(StartAppHibernatelication.class, args);
}
}

9.创建数据库表及插入数据

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
CREATE TABLE `t_user` (
`user_id` int(11) NOT NULL AUTO_INCREMENT,
`user_name` varchar(50) DEFAULT NULL,
`pass_word` varchar(50) DEFAULT NULL,
PRIMARY KEY (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8;


INSERT INTO `t_user` VALUES ('1', 'zhangsan', '00000');
INSERT INTO `t_user` VALUES ('2', 'lisi2', '123456');
INSERT INTO `t_user` VALUES ('3', 'lisi3', '123456');
INSERT INTO `t_user` VALUES ('4', 'lisi4', '123456');
INSERT INTO `t_user` VALUES ('5', 'lisi5', '123456');
INSERT INTO `t_user` VALUES ('6', 'lisi6', '123456');
INSERT INTO `t_user` VALUES ('7', 'lisi7', '123456');
INSERT INTO `t_user` VALUES ('8', 'lisi8', '123456');
INSERT INTO `t_user` VALUES ('9', 'lisi9', '123456');
INSERT INTO `t_user` VALUES ('10', 'lisi10', '123456');
INSERT INTO `t_user` VALUES ('11', 'lisi11', '123456');
INSERT INTO `t_user` VALUES ('12', 'lisi12', '123456');
INSERT INTO `t_user` VALUES ('13', 'lisi13', '123456');
INSERT INTO `t_user` VALUES ('14', 'lisi14', '123456');
INSERT INTO `t_user` VALUES ('15', 'lisi15', '123456');
INSERT INTO `t_user` VALUES ('16', 'lisi16', '123456');
INSERT INTO `t_user` VALUES ('17', 'lisi17', '123456');
INSERT INTO `t_user` VALUES ('18', 'lisi18', '123456');
INSERT INTO `t_user` VALUES ('19', 'lisi19', '123456');
INSERT INTO `t_user` VALUES ('20', 'lisi20', '123456');

10.启动项目,访问地址:localhost:8088/user/getAllUser ,访问结果如下

SpringBoot整合hibernate纯注解版 _ JavaClub全栈架构师技术笔记

四、整合的时候遇到的坑

1.注入数据层接口失败,启动时

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-30 10:57:19.756 ERROR 22892 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :

***************************
APPLICATION FAILED TO START
***************************

Description:

Field userDao in com.yang.service.impl.UserServiceImpl required a bean of type 'com.yang.dao.UserDao' that could not be found.


Action:

Consider defining a bean of type 'com.yang.dao.UserDao' in your configuration.

原因:在启动类上,只是用了@EnableJpaRepositories注解,但未将该注解指定数据层接口包名,需要指定数据层接口的包名,上面代码是已经修复过的,错误代码如下

SpringBoot整合hibernate纯注解版 _ JavaClub全栈架构师技术笔记

2.启动时,无法创建userDao,原因为无法创建bean

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
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.yang.bean.User
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1706) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:251) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1138) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 37 common frames omitted
Caused by: java.lang.IllegalArgumentException: Not a managed type: class com.yang.bean.User
at org.hibernate.metamodel.internal.MetamodelImpl.managedType(MetamodelImpl.java:473) ~[hibernate-core-5.2.17.Final.jar:5.2.17.Final]
at org.springframework.data.jpa.repository.support.JpaMetamodelEntityInformation.<init>(JpaMetamodelEntityInformation.java:73) ~[spring-data-jpa-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.jpa.repository.support.JpaEntityInformationSupport.getEntityInformation(JpaEntityInformationSupport.java:66) ~[spring-data-jpa-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getEntityInformation(JpaRepositoryFactory.java:181) ~[spring-data-jpa-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:119) ~[spring-data-jpa-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactory.getTargetRepository(JpaRepositoryFactory.java:102) ~[spring-data-jpa-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:298) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$3(RepositoryFactoryBeanSupport.java:287) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.util.Lazy.getNullable(Lazy.java:141) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.util.Lazy.get(Lazy.java:63) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:290) ~[spring-data-commons-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:102) ~[spring-data-jpa-2.0.7.RELEASE.jar:2.0.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1765) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1702) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
... 47 common frames omitted

解决方案:使用@EntityScan注解指定实体类的地址

SpringBoot整合hibernate纯注解版 _ JavaClub全栈架构师技术笔记

3.注解的顺序导致的项目无法启动@SpringBootApplication注解需要放到扫描包指定配置之后,否则数据层也无法依赖,实体类指向也不能生效(这个问题困扰了我两个小时)

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

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-01-30 11:07:22.925 ERROR 21064 --- [ restartedMain] o.s.boot.SpringApplication : Application run failed

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'useController': Unsatisfied dependency expressed through field 'userService'; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'userServiceImpl': Unsatisfied dependency expressed through field 'userDao'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDao': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Not a managed type: class com.yang.bean.User
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:587) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:91) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:373) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1348) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:578) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760) ~[spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550) ~[spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:327) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243) [spring-boot-2.0.2.RELEASE.jar:2.0.2.RELEASE]
at com.yang.boot.StartAppHibernatelication.main(StartAppHibernatelication.java:15) [classes/:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_91]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_91]
at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_91]
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.0.2.RELEASE.jar:2.0.2.RELEASE]

五、项目下载地址如下

点击我下载,小心你的鼠标

SpringBoot整合hibernate纯注解版 _ JavaClub全栈架构师技术笔记

作者:Java小白_Mr.Yang
来源链接:http://www.it-online.cn/2019/01/30/SpringBoot%E9%9B%86%E6%88%90hibernate/

版权声明:
1、JavaClub(https://www.javaclub.cn)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。


本文链接:https://www.javaclub.cn/java/10023.html

分享给朋友:

“SpringBoot整合hibernate纯注解版” 的相关文章

记一次SpringBoot项目使用RedisTemplate无法反序列化字节数组问题困扰8小时巨坑

记一次SpringBoot项目使用RedisTemplate无法反序列化字节数组问题困扰8小时巨坑

一、问题描述 问题描述: 前提:向Redis中SET值的是一个JFinal项目,使用的Jedis客户端API操作的,把一个对象转成byte[]形式存入Redis中。 然后在另一个SpringBoot项目中我通过Spring自带的RedisTempl...

前后端分离,SpringBoot如何实现验证码操作

前后端分离,SpringBoot如何实现验证码操作

验证码的功能是防止非法用户恶意去访问登录接口而设置的一个功能,今天我们就来看看在前后端分离的项目中,SpringBoot是如何提供服务的。SpringBoot版本本文基于的Spring Boot的版本是2.6.7 。引入依赖captcha一款超简单的验证码生成,还挺好玩的.还有中文验证码,动态验证码...

Spring Boot 自动配置的原理、核心注解以及利用自动配置实现了自定义 Starter 组件

Spring Boot 自动配置的原理、核心注解以及利用自动配置实现了自定义 Starter 组件

本章内容 自定义属性快速入门 外化配置 自动配置 自定义创建 Starter 组件 摘录:读书是读完这些文字还要好好用心去想想,写书也一样,做任何事也一样 图 2 第二章目录结构图 第 2...

Spring Boot 2.0 WebFlux 快速入门实践

Spring Boot 2.0 WebFlux 快速入门实践

02:WebFlux 快速入门实践 Spring Boot 2.0 spring.io 官网有句醒目的话是: BUILD ANYTHING WITH SPRING BOOT Spring Boot (Boot 顾名思义,是...

Spring Boot 2.x :通过 spring

Spring Boot 2.x :通过 spring

摘要: 原创出处 https://www.bysocket.com 「公众号:泥瓦匠BYSocket 」欢迎关注和转载,保留摘要,谢谢! 本文内容 HBase 简介和应用场景 spring-boot-starter-hbase 开源简介 集成 HB...

深入浅出 spring-data-elasticsearch

『  风云说:能分享自己职位的知识的领导是个好领导。 』 运行环境 :JDK 7 或 8,Maven 3.0+ 技术栈 :SpringBoot 1.5+, Spring Data Elasticsearch 1.5+ ,Elast...

Java回顾之Spring基础

Java回顾之Spring基础

这是针对Java进行回顾的一系列文章,这篇主要是和Spring基础相关。   第一篇:Java回顾之I/O   第二篇:Java回顾之网络通信   第三篇:Java回顾之多线程   第四篇:Java回顾之多线程同步   第五篇:Java回顾之集...

Spring Batch 读 10 万条记录,写到 MongoDB

实践内容 从 MariaDB 一张表内读 10 万条记录,经处理后写到 MongoDB 。 具体实现 1、新建 Spring Boot 应用,依赖如下: <!-- Web 应用 -->...

SpringBoot整合MybatisPlus 实现多租户

SpringBoot整合MybatisPlus 实现多租户

代码已经上传到码云:https://gitee.com/lezaiclub/springboot-hyper-integration.git,欢迎白嫖 引言 今天我们来聊聊多组户 其实多租户主要讲的是数据隔离,即每个企业或用户都享有自己的独立...

Spring Boot 使用 Maven 定制一个 parent 简化开发

Spring Boot 使用 Maven 定制一个 parent 简化开发

1/ 场景 有很多小应用,有一些公共的特点,比如说都依赖了spring-boot、log4j2、lombok、fastjson等等,为了方便开发,可以使用Maven定制一个parent来简化开发,统一管理第三方依赖的版本。(为后续的微服务做准备哦!...

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。