Spring
土耳其的烧烤
这个作者很懒,什么都没留下…
展开
-
CrudRepository接口中的方法理解
CrudRepository中的方法(这个接口提供了基本增删改查方法)save(entity):添加一条数据save(entities):添加多条数据entities为集合findOne(id):根据id查询一条数据exists(id):判断id是否存在findAll():查询全部数据delete(id):根据id删除数据delete(entity):根据一条数据的信息删除数据delete(entities):根据多条数据的信息删除数据deleteAll():删除全部信息一、Re原创 2021-11-15 15:00:32 · 505 阅读 · 0 评论 -
oauth2.0 07 授权方式 存数据库--未完结,服务启动失败
第一步 加表结构:CREATE TABLE `oauth_client_details` ( `client_id` varchar(256) NOT NULL, `resource_ids` varchar(256) DEFAULT NULL, `client_secret` varchar(256) DEFAULT NULL, `scope` varchar(256) DEFAULT NULL, `authorized_grant_types` varchar(256) DEFAU...原创 2021-11-10 15:08:40 · 780 阅读 · 0 评论 -
oauth2.0 06 使用jwt
需要使用 jwt 转换器新增import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;@Configurationpublic class JwtTo原创 2021-11-10 14:31:51 · 81 阅读 · 0 评论 -
oauth2.0 05 refresh_token
refresh_token 只有 password 和authorization_code 两种方式才有,client_credentials方式 是不会返回refresh_token的!!我们依旧要在代码中authorizedGrantTypes加一个refresh_token才可以.authorizedGrantTypes("authorization_code","password","client_credentials","refresh_token")请求模式 和前面...原创 2021-11-10 14:18:04 · 417 阅读 · 0 评论 -
oauth2.0 04 客户端凭证认证 方式
微信貌似使用的就是这种方式这种方式 只需要在前两者稍微 改一丢丢就可以了 postman 请求一共三个参数在加了@EnableAuthorizationServer类中加一个授权模式:client_credentials.authorizedGrantTypes("authorization_code","password","client_credentials")...原创 2021-11-10 14:06:05 · 157 阅读 · 0 评论 -
oauth2.0 03 密码认证模式
使用密码认证模式 需要我们在 加了@EnableWebSecurity注解的类中加AuthenticationManager 的Bean对象,不加这个代码是用不了密码模式的!@Bean @Override public AuthenticationManager authenticationManagerBean() throws Exception{ return super.authenticationManagerBean(); }截图如下:...原创 2021-11-10 13:51:04 · 726 阅读 · 0 评论 -
oauth2.0 02 授权码模式
授权码 模式http://localhost:8888/oauth/authorize?client_id=client&scope=app&response_type=code在 spring1 的基础上新增2个类package com.example.demo.auth.config;import org.springframework.context.annotation.Bean;import org.springframework.context.ann原创 2021-11-10 01:20:13 · 310 阅读 · 0 评论 -
oauth2.0 01 创建项目
注意 spring boot 版本2.3.1.RELEASE<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https:/原创 2021-11-10 00:28:08 · 392 阅读 · 0 评论 -
从0创建eureka 注册中心-单机版
添加 EnableEurekaServer配置eurekaserver.port=8172eureka.instance.hostname=localhost#禁止自己当做服务注册eureka.client.register-with-eureka=false#屏蔽注册信息eureka.client.fetch-registry=falseeureka.client.service-url.defaultzone: http://${eureka.instance....原创 2021-11-04 17:02:54 · 50 阅读 · 0 评论 -
FeignClient方式调用第三方接口
用此方式代替httpclient类似的繁杂请求@Component@FeignClient(name = "TestClient", url = "${host}", path = "/xxx")public interface TestClient { @PostMapping("/test") DataVo test(@RequestBody DataReq req);}翻译 2021-01-26 18:31:56 · 2324 阅读 · 0 评论 -
Spring 开启注解的方式方式——spring必须了解的几个接口系列二
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://ww...原创 2019-03-17 17:40:00 · 247 阅读 · 0 评论 -
Spring 获取Request,Response对象的几种方式--未验证
第一种、参数@RequestMapping("/test")@ResponseBodypublic void saveTest(HttpServletRequest req, HttpServletResponse resp){ }第二种、注解 @Autowired private HttpServletRequest request; 第三种、上下文获取...原创 2018-11-26 16:36:01 · 472 阅读 · 0 评论 -
Spring 4.3 的有哪些新鲜花样
核心容器改进核心容器额外提供了更丰富的元数据来改进编程。默认 Java 8 的方法检测为 bean 属性的 getter/setter 方法。如果目标 bean 只定义了一个构造函数,则它无需要指定@Autowired注解@Configuration类支持构造函数注入。任何 SpEL 表达式用于指定@EventListener的condition引用到 bean(例如@beanName原创 2016-07-07 14:33:20 · 2214 阅读 · 0 评论 -
Spring中 @Autowired标签与 @Resource标签 的区别
Spring不但支持自己定义的@Autowired注解,还支持由JSR-250规范定义的几个注解,如:@Resource、 @PostConstruct及@PreDestroy。1. @Autowired @Autowired是Spring 提供的,需导入 Package:org.springframework.beans.factory.annotation.Autowi原创 2015-07-13 21:32:05 · 281 阅读 · 0 评论