spring
xiewz1112
这个作者很懒,什么都没留下…
展开
-
Spring学习--4 集合属性注入
Spring中��Bean中注入集合属性时,首先将一系列的基本类型和对象注入到集合中,再将集合注入Bean中。<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/20...原创 2018-05-25 15:56:11 · 417 阅读 · 0 评论 -
spring学习--13 condition
采用@Conditional和接口Condition实现基于条件的Bean的创建,可代替active的profile。一般用于多态下的Bean的创建。示例如下。1. 通过接口Condition定义条件window操作系统条件package com.condition;import org.springframework.context.annotation.Condition;...原创 2018-05-29 18:18:27 · 121 阅读 · 0 评论 -
spring学习--14 总结
关键概念: 1、依赖注入:通过组合,而非继承关系,由Spring IoC container(ApplicationContext)管理注入所需Bean,实现Bean直接的解耦合。 2、Java配置:通过@Configuration和@Bean实现,取代复杂的xml配置方式。如果配置类有@ComponentScan注解,并且被扫描的类具有@Component、@Repository、@Serv...原创 2018-05-29 17:11:46 · 106 阅读 · 0 评论 -
spring学习--12 @Enable*注解工作原理
所有@Enable*已经注解的元注解中均包含@Import注解,@Import用于导入配置类,因此@Enable*注解通过导入配置类实现*所标注功能的使能。如@EnableAsync、@EnableScheduling、@EnableAspectJAutoProxy等等。 导入配置类方式分为三种: 1、直接导入配置类,如@EnableScheduling导入SchedulingConfigur...原创 2018-05-29 15:45:09 · 412 阅读 · 0 评论 -
spring学习--11 composed annotation and meta annotation
组合注解与其注解的注解具有相同的作用1. 组合注解package com.annotation;import java.lang.annotation.Documented;import java.lang.annotation.ElementType;import java.lang.annotation.Retention;import java.lang.annotat...原创 2018-05-29 15:19:40 · 188 阅读 · 0 评论 -
Spring学习--3 EL和资源调用
Spring学习–3 EL和资源调用目的:学习掌握EL和资源调用方法。 过程:通过编程学习实现。 工具:Spring tool suit 难度:一颗星1、同classpath下编写test.txt和test.properties文件,前者内容自定,后者满足格式即可,如:book.author=Cruisebook.name=spring boot2、编写Service...原创 2018-05-24 13:47:26 · 188 阅读 · 0 评论 -
spring学习--10 Scheduled
难度:一颗星1. Scheduled servicepackage com.schedule;import java.text.SimpleDateFormat;import java.util.Date;import org.springframework.scheduling.annotation.Scheduled;import org.springframework...原创 2018-05-28 23:43:40 · 89 阅读 · 0 评论 -
spring学习--9 多任务
spring采用TaskExecutor完成多任务处理工作和并发编程,可以使用TheadPoolTaskExecutor创建一个基于线程池的TaskExecutor。如下例所示。1、Configuration类package com.taskexecutor;import java.util.concurrent.Executor;import org.springframew...原创 2018-05-28 21:20:48 · 214 阅读 · 0 评论 -
Spring学习--8 aware
Spring Awarespring aware包括BeanNameAware、BeanFactoryAware、ApplicationContextAware、MessageSourceAware、ApplicationEventPublisherAware、ResourceLoaderAware等,采用spring aware可获取Spring容器本身的功能资源,不利之处在于将Bean与S...原创 2018-05-28 20:13:34 · 128 阅读 · 0 评论 -
spring学习--7 event
过程:定义一个event和一个listener,再在event publisher class中通过ApplicationEvent.publishEvent(java.lang.Object event)方法发布事件。1、Eventpackage com.event;import org.springframework.context.ApplicationEvent;pub...原创 2018-05-28 16:16:26 · 123 阅读 · 0 评论 -
spring学习--6 profile
1、激活Profile的几种方式Spring通过两个不同属性来决定哪些profile可以被激活(注意:profile是可以同时激活多个的),一个属性是spring.profiles.active和spring.profiles.default。这两个常量值在Spring的AbstractEnvironment中有定义,查看AbstractEnvironment源码: /** ...原创 2018-05-28 14:01:53 · 154 阅读 · 0 评论 -
Spring学习--5 Bean生命周期管理
Bean生命周期管理目的:掌握Bean生命周期管理方法,主要是标明initMethod和destroyMethod方法。 两种形式可用来管理Bean的初始化和销毁,一种是在配置中采用@Bean注解,@Bean(initMethod=”INIT_METHOD”, destroyMethod=”DESTROY_METHOD”);另外一种是在Bean的方法上分别注解@PostConstruct和@...原创 2018-05-28 10:07:18 · 118 阅读 · 0 评论 -
Spring学习--2 aop
Spring学习–2 aop演示了aop的两种拦截方式:基于注解规则拦截和基于方法规则进行拦截。 步骤:添加依赖->编写基于注解拦截的规则->被拦截类->切面->java配置类->bootrap类添加依赖(pom.xml)<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="h...原创 2018-05-23 14:22:22 · 86 阅读 · 0 评论 -
在Spring Cloud Config中加密git到远程数据库中信息
过程:Spring Cloud Config 包括Server和Client端,Server端可以对配置文件中的属性信息进行加密,Client端获取配置信息,配置信息中的加密属性信息自动解密。具体步骤如下:步骤1采用Spring Cloud Config的Finchley.SR1版本,配合SpringBoot 2.0使用。在使用Finchley.SR1时,需要将Java SE的jre/lib/...原创 2018-10-16 15:41:48 · 683 阅读 · 0 评论