Spring Java中的模板类是什么?为什么将它们称为模板?例如jdbc-template,jms-template等 [英] What are template classes in Spring Java? Why are they called templates? For example jdbc-template, jms-template etc

查看:345
本文介绍了Spring Java中的模板类是什么?为什么将它们称为模板?例如jdbc-template,jms-template等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Java的新手.我只编程了大约一年. Spring通过使用模板意味着什么?在Spring中,有jdbc-templates,jms-templates等.java中的模板类是什么?它们是一种特殊的设计模式还是什么?

I'm new to Java. I've only been programming it for about a year. What does Spring mean by the use of templates? In Spring, there is jdbc-templates, jms-templates etc.. What are template classes in java? Are they a special kind of design pattern or what?

谢谢.

推荐答案

使用模板方法模式.

基本上,这个想法是定义在抽象类或超类中执行某项操作所需的操作,然后实现一个使用先前定义的操作的类.

Basically the idea is define the operation needed to do something in an abstract class or super class then implement a class that use the operation previous defined.

在使用spring的情况下,可以自动执行总是需要针对特定​​目的进行的操作(打开连接,获取池,转换,执行,关闭连接),那么用户只需要调用方法而无需担心关于以前的任务.

In the case of spring allow that operation that always need to be done for an specific purpose be done automatically, (open connection, obtain for pool, translation, execution, close connection), then user only need to call methods without worries about the previous tasks.

这篇关于Spring Java中的模板类是什么?为什么将它们称为模板?例如jdbc-template,jms-template等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆