Spring Boot
文章平均质量分 63
Spring Boot
coffeesunshine
这个作者很懒,什么都没留下…
展开
-
SpringCloud之微服务(八)之服务追踪之sleuth,zipkin下载安装配置可视化
文章目录1、分别在order,product项目引入依赖sleuth2、zipkin下载安装配置可视化1、zipkin下载可视化2、浏览器打开3、分别在order,product项目引入依赖sleuth3、(可选这种包含sleuth和zipkin)引入依赖,spring-cloud-starter-zipkin。4、配置zipkin1、分别在product和order项目的yml,配置spring.zipkin.base-url和spring.sleuth.sampler.probability和sprin原创 2022-03-23 23:34:28 · 768 阅读 · 0 评论 -
SpringCloud之微服务(七)之服务容错和Hystrix、zuul超时配置,feign-hystrix,hystrix-dashboard
文章目录0、代码参考1、触发降级1、引入依赖2、启动类添加@SpringCloudApplication或者(@EnableCircuitBreaker)3、添加@HystrixCommand注解4、默认注解@DefaultProperties(defaultFallback = "defaultFallback")5、全局服务降级@DefaultProperties(defaultFallback = "defaultFallback")2、超时设置3、在order项目的配置文件bootstrap.yml原创 2022-03-23 22:29:39 · 252 阅读 · 0 评论 -
SpringBoot之RabbitMQ之Header 模式
版本:SpringBoot2.1.7.RELEASE0、pom依赖:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency>1、HeaderConfigpackage cn.linst.amqp1.config;import or原创 2021-07-21 22:10:19 · 735 阅读 · 0 评论 -
SpringBoot之RabbitMQ之Direct 模式
版本:SpringBoot2.1.7.RELEASE安装RabbitMQ,启动RabbitMQ。0、pom.xml添加依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp</artifactId> </dependency>完整pom:<?xml versio原创 2021-07-21 20:58:16 · 245 阅读 · 3 评论 -
SpringBoot 之Spring Security自动登录功能
版本SpringBoot2.2.6.RELEASE1、pom.xml依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <grou原创 2021-07-13 16:58:02 · 178 阅读 · 0 评论 -
OAuth2令牌刷新
版本:springboot2.2.6.RELEASE参考文章:OAuth2密码模式这里采用oauth2密码模式,postman工具1、获取令牌2、带上access_token去访问user-server接口,如:或者这样:3、刷新令牌修改请求参数,如下:grant_type refresh_token,refresh_token 的value等于上面请求的refresh_token返回了新的access_token4、旧的access_token已经失效5、换成新的acc原创 2021-05-25 22:05:16 · 675 阅读 · 1 评论 -
OAuth2简化模式
版本:springboot2.2.6.RELEASE参考文章:OAuth2 授权码模式做如下修改:1、auth-server(授权服务器)修改configure(ClientDetailsServiceConfigurer) 方法部分:只需要在 authorizedGrantTypes 中增加 implicit 表示支持简化模式即可。AuthorizationServer:package cn.linst.authserver.config;import org.springframewor原创 2021-05-24 21:56:19 · 838 阅读 · 6 评论 -
springboot之整合jdbctemplate
版本:springboot.2.1.6.RELEASE1、添加依赖:pom.xml:<!-- jdbc--><dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-jdbc</artifactId></dependency><!-- 数据库连接池--><de原创 2021-04-01 19:56:22 · 123 阅读 · 0 评论 -
springboot之整合mybatis
版本:springboot.2.1.6.RELEASE1、引入依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId></dependency><dependency> <groupId>org.mybatis.spring.原创 2021-03-31 23:55:32 · 309 阅读 · 0 评论 -
springboot之整合aop
版本:springboot2.1.6.RELEASE1、pom.xml依赖<?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 h原创 2021-03-31 19:52:55 · 123 阅读 · 0 评论 -
springboot之自定义欢迎页面
版本:springboot.2.1.6.RELEASE1、pom依赖pom.xml:<?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原创 2021-03-30 23:28:13 · 314 阅读 · 0 评论 -
springboot之类型转换器-日期转换器
版本:springboot.2.1.6.RELEASE1、pom依赖pom.xml:<?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原创 2021-03-30 23:17:11 · 204 阅读 · 0 评论 -
springboot之路径映射
版本springboot2.1.6.RELEASE1、pom依赖<?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-03-30 23:03:23 · 233 阅读 · 0 评论 -
springboot之commandlinerunner
版本:springboot2.1.6.RELEASE1、pom依赖:<?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 http原创 2021-03-30 21:19:59 · 265 阅读 · 0 评论 -
springboot学习28
一、使用SpringBootAdmin1、创建Admin服务器Admin服务器通常会作为一个单独的应用。添加依赖:admin-server的版本要低于等于admin-client的版本,否则会无法注册进服务。<dependency> <groupId>de.codecentric</groupId> <artifactId>spring-boot-admin-starter-server</artifactId> <ve原创 2021-03-04 16:56:18 · 425 阅读 · 1 评论 -
springboot学习27
一、了解Actuator为了在Springboot 应用中启用Actuator,需要在构建文件中添加Actuator starter依赖。在pom.xml添加以下依赖: <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency&g原创 2021-03-04 14:48:33 · 8349 阅读 · 1 评论 -
springboot学习26
1、SpringData的响应式repository1)响应式repository,要接受和返回Mono和Flux的方法,而不是领域实体和集合。查询:Flux<Ingredient> findByType(Ingredient.Type type);保存:<Taco> Flux<Taco> saveAll(Publisher<Taco> tacoPublisher);2)响应式和非响应式转换如:在关系型数据库并用SpringDataJPA进行原创 2021-03-01 16:29:05 · 794 阅读 · 0 评论 -
springboot学习25
一、使用SpringWebFlux1、pom.xml引入依赖:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-webflux</artifactId></dependency>WebFlux 的默认嵌入式服务器是 Netty 而不是 Tomcat。1)返回单个值:@GetMapp原创 2021-02-18 20:32:14 · 350 阅读 · 0 评论 -
springboot学习24
一、响应式流接口定义:Publisher,Subscriber,Subscription 和 Processor。Publisher 接口声明了一个 subscribe() 方法:public interface Publisher<T> { void subscribe(Subscriber<? super T> subscriber);}Subscriber 如果订阅了,就可以从 Publisher 中接收消息。Subscriber:public inte原创 2021-02-18 14:32:36 · 305 阅读 · 0 评论 -
springboot学习23
email集成流:@Data// 使用了 @ConfigurationProperties 注解,可以在 application.yml 配置文件中配置@ConfigurationProperties(prefix="springbootlearn.email")@Componentpublic class EmailProperties { private String username; private String password; private String h原创 2021-02-17 18:44:59 · 151 阅读 · 0 评论 -
springboot学习22
一、集成流integration。pom.xml引入依赖:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-integration</artifactId></dependency><dependency> <groupId>org.springfra原创 2021-02-17 16:20:37 · 4315 阅读 · 2 评论 -
springboot学习21
异步消息-kaffaKafka 是一个消息代理。Kafka topic 被复制到集群中的所有 broker 中,Kafka 集群由多个 broker 组成。集群中的每个节点充当一个或多个 topic 的 leader,负责该 topic 的数据并将其复制到集群中的其他节点。一、在spring中设置kafka在pom.xml引入依赖:Kafka 没有 Spring Boot starter。<dependency> <groupId>org.springframewo原创 2021-02-13 22:32:57 · 141 阅读 · 0 评论 -
springboot学习20
异步消息-RabbitMQ及AMQPRabbitMQ是 AMQP实现,AMQP 消息使用交换器的名称和路由键来寻址。几种交换方式:DefaultDirectTopicFanoutHeadersDead letter一、RabbitTemplate发送消息1、添加 RabbitMQ 到 Spring 中pom.xml引入依赖<dependency> <groupId>org.springframework.boot<原创 2021-02-13 21:59:13 · 285 阅读 · 0 评论 -
springboot学习19
一、异步信息-使用JMS1、设置 JMSpom.xml引入依赖:如果使用ActiveMQ:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-activemq</artifactId></dependency>ActiveMQ 特定的属性:属性描述spring.原创 2021-02-13 20:25:58 · 146 阅读 · 1 评论 -
springboot学习18
Spring 应用程序可以通过以下方式使用 REST API:一、RestTemplate由 Spring 核心框架提供、简单、同步 REST 客户端。RestTemplate 定义操作:方法描述delete(…)对指定 URL 上的资源执行 HTTP DELETE请求exchange(…)对 URL 执行指定的 HTTP 方法,返回一个 ResponseEntity,其中包含从响应体映射的对象execute(…)对 URL 执行指定的 HTTP 方法,返回一个原创 2021-02-13 12:53:32 · 85 阅读 · 0 评论 -
springboot学习17
一、rest服务Spring MVC HTTP 请求处理注解注解HTTP 方法用法@GetMappingHTTP GET 请求读取资源@PostMappingHTTP POST 请求创建资源@PutMappingHTTP PUT 请求更新资源@PatchMappingHTTP PATCH 请求更新资源@DeleteMappingHTTP DELETE 请求删除资源@RequestMapping通用请求处理1、获取数据从服务原创 2021-02-13 10:42:18 · 170 阅读 · 1 评论 -
springboot学习16
一、 自动配置:1、 Spring 环境1)应用程序属性配置文件Spring Boot 自动配置的 bean 都可以通过从 Spring 环境中提取的属性进行配置。在 src/main/resources/application.propertiesapplication.properties:server.port=8081或者在src/main/resources/application.ymlapplication.yml :server: port: 80812)命令行参原创 2021-02-12 20:20:01 · 117 阅读 · 2 评论 -
springboot学习15
Spring Security一、配置Spring Security。在 pom.xml 文件中引入依赖:<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId></dependency>有几种配置 Spring Security 的方法,包括冗长原创 2021-02-12 00:58:33 · 97 阅读 · 3 评论 -
springboot学习14
一、使用 Spring JdbcTemplate:首先使用 Spring 对 JDBC(Java Database Connectivity)的支持来消除样板代码。然后,将重新使用 JPA(Java Persistence API)处理数据存储库,从而消除更多代码。Spring JDBC 支持起源于 JdbcTemplate 类。JdbcTemplate 提供了一种方法,通过这种方法,可以对关系数据库执行 SQL 操作,与通常使用 JDBC 不同的是,这里不需要满足所有的条件和样板代码。在没有 Jdb原创 2021-02-11 13:37:48 · 149 阅读 · 0 评论 -
springboot学习13
springboot1、支持的模板选项:表1.1模板Spring Boot starter 依赖FreeMarkerspring-boot-starter-freemarkerGroovy Templatesspring-boot-starter-groovy-templatesJavaServer Page(JSP)None (provided by Tomcat or Jetty)Mustachespring-boot-starter-mustache原创 2021-02-10 22:43:12 · 120 阅读 · 0 评论 -
springboot学习12
Spring Web MVC REST1、REST资源操作HTTP :GET、PUT、POST、DELETE原创 2021-02-09 14:10:44 · 67 阅读 · 0 评论 -
springboot学习11
1、视图内容协商交互流程:1、ContentNegotiationConfigurer- - -关联- - ->ContentNegotiationManagerFactoryBean2、ContentNegotiationConfigurer - - - 配置 - - ->ContentNegotiationStrategy 实现(PathExtensionContentNegotiationStrategy、ParameterContentNegotiationStrategy、Fix原创 2021-02-08 19:36:22 · 131 阅读 · 0 评论 -
springboot学习10
一、模板引擎Thymeleaf。1)资源定位(模板来源 ): 通用资源抽象 文件资源: File ClassPath资源: ClassLoader 统一资源: URL Web资源: ServletContext Spring 资源抽象: Spring 资源: Resource2)渲染上下文(变量来源 ) 不同的实现 Context :Thyemeaf 渲染上下文 Model :Spring Web MVC 模型 Attribute :Servlet 上下文原创 2021-02-08 16:36:05 · 82 阅读 · 0 评论 -
springboot学习9
springwebmvc简化之springboot :1.1、完全自动装配spirngwebmvcspringbooot自动装配DispatcherServletDispatcherServletAutoConfiguration替换@EnableWebMvcWebMvcAutoConfigurationServlet 容器:ServletWebServerFactoryAutoConfiguration1.1.2、自动配置顺序性:原创 2021-02-07 21:34:55 · 81 阅读 · 0 评论 -
springboot学习8
1、Spring Web MVC 核心组件组件 Bean 类型说明HandlerMapping映射请求(Request)到处理器(Handler)加上其关联的拦截器 (HandlerInterceptor)列表,其映射关系基于不同的 HandlerMapping 实现的一些 标准细节。其中两种主要 HandlerMapping 实现, RequestMappingHandlerMapping 支持标注 @RequestMapping 的方法, SimpleUrlHandlerMapp原创 2021-02-07 17:59:32 · 85 阅读 · 0 评论 -
springboot学习7
SpringApplication:1、SpringApplication基本使用:1.1 SpringApplication运行SpringApplication.run(DemoSpringBootApplication.class, args)1.2、自定义SpringApplication1)通过SpringApplicationAPI 方式SpringApplication springApplication = new SpringApplication(DemoSpringBoo原创 2021-02-06 19:49:51 · 184 阅读 · 0 评论 -
springboot学习6
Spring 手动配置之条件装配:Spring Framework 3.1 Since,允许在 Bean 装配时增加前置条件判断。Spring注解说明起始版本@Profile配置化条件装配3.1@Conditional编程条件装配4.02种方式:配置方式 @Profile编程方式 @Conditional@Target({ ElementType.TYPE, ElementType.METHOD })@Retention(RetentionPolicy.原创 2021-02-05 17:51:29 · 66 阅读 · 0 评论 -
springboot学习5
Spring手动装配之Spring @Enable 模块装配:1、@Enable注解模块框架实现@Enable注解激活模块Spring Framework@EnableWebMvcWeb MVC 模块Spring Framework@EnableTransactionManagement事务管理模块Spring Framework@EnableCachingCaching 模块Spring Framework@EnableMBeanExportJM原创 2021-02-05 17:02:46 · 56 阅读 · 0 评论 -
springboot学习4
1、spring注解Spring Framework 注解场景起始版本@Repository数据仓储2.0@Component通用组件2.5@Service服务2.5@ControllerWeb控制器2.5@Configuration配置类3.02、装配方式1)<context:component-scan> (since spring2.5)<?xml version="1.0" encoding="UTF-8原创 2021-02-05 14:36:52 · 65 阅读 · 0 评论 -
memcached
springboot 引入memcached0、安装memcache启动memcache1、pom.xml 引入依赖 <dependency> <groupId>net.spy</groupId> <artifactId>spymemcached</artifactId> <version>2.12.2</version> </dependency>MemcachedC原创 2021-02-02 17:08:43 · 90 阅读 · 0 评论