随笔分类 - Spring
摘要:1.获取所有指定注解的类的bean信息 Map<String, Object> beansWithAnnotationMap = this.applicationContext.getBeansWithAnnotation(RespMegTypeSup.class); String[] beanNa
阅读全文
摘要:Propagation是一个枚举,定义了七大行为类型,下以分别解释。 REQUIRED(TransactionDefinition.PROPAGATION_REQUIRED) 官方解释:支持当前事务;如果不存在,就创建一个新的。类似于同名的EJB事务属性。这通常是交易定义的默认设置,通常定义事务同步
阅读全文
摘要:一、@SpringBootApplication是一个复合注解或派生注解,在@SpringBootApplication中有一个注解@EnableAutoConfiguration,该注解开启自动配置。 1、@SpringBootApplication组合注解 二、@EnableAutoConfig
阅读全文
摘要:1、创建注解MineControllerMineAutowiredMineRequestMappingMineRequestParamMineServiceMineDao 1.1、注入注解 @Target(ElementType.FIELD) @Retention(RetentionPolicy.R
阅读全文
摘要:Spring 注解@Component,@Service,@Controller,@RepositorySpring 2.5 中除了提供 @Component 注释外,还定义了几个拥有特殊语义的注释,它们分别是:@Repository、@Service 和 @Controller。在目前的 Spri
阅读全文
摘要:1、@Component:把普通pojo实例化到spring容器中,相当于配置文件中的 2、@Autowired:Spring框架中进行对象注入 @Component public class Person { private String id; private String name; private String sex; //getter/setter省略 } @S...
阅读全文
摘要:AOP是OOP的延续,是Aspect Oriented Programming的缩写,意思是面向切面编程。可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种技术。AOP实际是GoF设计模式的延续,设计模式孜孜不倦追求的是调用者和被调用者之间的解耦,AOP可以说也
阅读全文
摘要:一、表单验证 二、AOP处理请求 AOP是一种编程范式。与语言无关,是一种程序设计思想。 面向过程到面向对象。换个角度看世界,换个姿势处理问题。 2.1AOP实例-http请求 MAVEN添加依赖:org.springframework.boot 类: @Aspect @Component publ
阅读全文
摘要:创建springBoot项目 通过IDEA的Spring Initializr创建springBoot项目 一、三种启动方式 1.DemoApplication.java启动类 -> 打开 -> 右击 -> run DemoApplication 2.项目根目录 -> mvn spring-boot
阅读全文
摘要:@RequestBody 将HTTP请求正文转换为适合的HttpMessageConverter对象。 @ResponseBody 将内容或对象作为 HTTP 响应正文返回,并调用适合HttpMessageConverter的Adapter转换对象,写入输出流。 /** * @return 返回Pe
阅读全文
摘要:Spring将事务管理分成了两类 一、编程式事务管理:(不常用) transactionTemplate.execute(new TransactionCallback<People>() { @Override public People doInTransaction(TransactionSt
阅读全文
摘要:@RunWith(SpringJUnit4ClassRunner.class)让测试运行于Spring测试环境 @ContextConfiguration 用来指定加载的Spring配置文件的位置,会加载默认配置文件 加载Spring配置文件:@ContextConfiguration(classp
阅读全文
摘要:一、属性文件:version.properties -》内容:version=201608 二、java代码 三、 applicationContext.xml配置 <bean class="com.zhihui.base.configVersion " init-method="init"></b
阅读全文
摘要:@Controller @RequestMapping("/reg") public class RegController extends BaseController { @Value("${jdbc.url}") private String signDetail; //取jdbc.url属性值
阅读全文