×

spring整合mybatis步骤 pring is

spring整合mybatis怎样配置注解?求翻译!

admin admin 发表于2022-06-14 15:57:31 浏览114 评论0

抢沙发发表评论

spring整合mybatis怎样配置注解


mybatis和spring的整合步骤:
1)使用mybatis,必须有个全局配置文件configuration.xml,来配置mybatis的缓存,延迟加载等等一系列属性,该配置文件示例如下:

Java代码
《?xml version=“1.0“ encoding=“UTF-8“ ?》
《!DOCTYPE configuration
PUBLIC “-//ibatis.apache.org//DTD Config 3.0//EN“


3)需要一个sessionFactory来生成session,sessionFactory配置如下:

Java代码
《bean id=“testSqlSessionFactory“ class=“org.mybatis.spring.SqlSessionFactoryBean“》
《property name=“configLocation“ value=“classpath:configuration.xml“ /》
《property name=“dataSource“ ref=“testDataSource“ /》
《/bean》

4)配置一个映射器接口来对应sqlSessionTemplate,该映射器接口定义了接口方法:
Java代码
《!-- data OR mapping interface --》
《bean id=“testMapper“ class=“org.mybatis.spring.mapper.MapperFactoryBean“》
《property name=“sqlSessionFactory“ ref=“testSqlSessionFactory“ /》
《property name=“mapperInterface“ value=“com.wotao.taotao.persist.test.mapper.TestMapper“ /》
《/bean》

5)至此,一个完整的myabtis整合spring的配置文件看起来应该如下所示:

Java代码
《?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://www.springframework.org/schema/context“
xmlns:tx=“http://www.springframework.org/schema/tx“ xmlns:aop=“http://www.springframework.org/schema/aop“
xsi:schemaLocation=“http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd“》

《!-- c3p0 connection pool configuration --》
《bean id=“testDataSource“ class=“com.mchange.v2.c3p0.ComboPooledDataSource“
destroy-method=“close“》
《property name=“driverClass“ value=“${db.driver.class}“ /》
《property name=“jdbcUrl“ value=“${db.url}“ /》
《property name=“user“ value=“${db.username}“ /》
《property name=“password“ value=“${db.password}“ /》
《property name=“initialPoolSize“ value=“5“ /》
《property name=“minPoolSize“ value=“5“ /》
《property name=“maxPoolSize“ value=“20“ /》
《property name=“maxStatements“ value=“100“ /》
《property name=“maxIdleTime“ value=“3600“ /》
《property name=“acquireIncrement“ value=“2“ /》
《property name=“acquireRetryAttempts“ value=“10“ /》
《property name=“acquireRetryDelay“ value=“600“ /》
《property name=“testConnectionOnCheckin“ value=“true“ /》
《property name=“idleConnectionTestPeriod“ value=“1200“ /》
《property name=“checkoutTimeout“ value=“10000“ /》
《/bean》
《bean id=“testSqlSessionFactory“ class=“org.mybatis.spring.SqlSessionFactoryBean“》
《property name=“configLocation“ value=“classpath:configuration.xml“ /》
《property name=“dataSource“ ref=“testDataSource“ /》
《/bean》
《!-- data OR mapping interface --》
《bean id=“testMapper“ class=“org.mybatis.spring.mapper.MapperFactoryBean“》
《property name=“sqlSessionFactory“ ref=“testSqlSessionFactory“ /》
《property name=“mapperInterface“ value=“com.wotao.taotao.persist.test.mapper.TestMapper“ /》
《/bean》

《!-- add your own Mapper here --》

《!-- comment here, using annotation --》
《!-- 《bean id=“sqlSessionTemplate“ class=“org.mybatis.spring.SqlSessionTemplate“》 --》
《!-- 《constructor-arg index=“0“ ref=“sqlSessionFactory“ /》 --》
《!-- 《/bean》 --》
《!-- base DAO class, for module business, extend this class in DAO --》
《!-- 《bean id=“testBaseDAO“ class=“com.test.dao.TestBaseDAO“》 --》
《!-- 《property name=“sqlSessionTemplate“ ref=“sqlSessionTemplate“ /》 --》
《!-- 《/bean》 --》
《!-- 《bean id=“testDAO“ class=“com.test.dao.impl.TestDAOImpl“ /》 --》

《!-- you can DI Bean if you don’t like use annotation --》

《/beans》

求翻译!


1.李实
李实(人名)以讨好巴结之法奉承李齐运,很快的就升迁到京兆尹(首都的市长)的位置。仗着自己得宠而刚愎逞强,不顾纲常法纪。当时有一年春夏都遇上旱灾,首都及附近都因此缺少粮食。但“李实”根本不已此为意,只顾着聚敛财物,征发民力,用这些来进献给上位者。每当跟皇帝谈论公务时,还说“今年虽然大旱了,但是粮食收成很好”。就这样地租杂税都没有免除,人们更穷了,以至于毁坏房屋而出卖瓦片,木材,借来麦苗而向官差们交差。有一个戏子叫成辅端的作民谣讽刺他,“李实”知道此事后,上报朝廷说成辅端污蔑朝廷的政策,于是成辅端被用棍子活活杖责而死。
一日,“李实”在路上遇见了御史王播,他编造说:京兆尹与御史在路上遇见了,京兆尹离开大路让开了御史的车架。(事实是)“李实”没有避让,指挥车骑的人依然前行。王播责骂了(自己这边)让开了“李实”车骑的人。“李实”知道后很生气,上报了皇帝让王播担任“三原令”的职务,这让朝廷的其他人很是诟病。“李实”欺凌自公卿以下的人,随着自己的喜怒向皇帝随意污蔑大臣,让他们被降职、罢免,使得朝廷的大臣们更怕他了。曾经有道皇帝的诏书宣布免除了首都附近的租税,但是“李实”根本不执行诏书上的命令,像原来一样征收租税。“李实”敢于杀人,害人,这导致人们和小官吏们没法生活。到了他倒台的时候,整座城市欢呼雀跃,都在袖子里藏着瓦片、石子,挡住道路等着他,“李实”因为走了另外一条路而逃脱了。

2.巢谷

绍圣年初,我(苏辙)因为获罪被罢免住在筠州,然后从筠州搬到雷州,再搬到循州。我哥哥子瞻(苏轼)也从惠州搬到昌化,士大夫们都不敢和我们兄弟来往了,亲戚朋友也再没有联络了。只有巢谷在眉山扬言要徒步寻访我们兄弟俩。听见的人都笑他痴狂。元符二年正月,他从梅州给我来信说:“我步行万里来见你,自己没有意料到还能保全性命,现在到梅州了,很快就能相见,虽死无恨了。”我惊喜地说:“他不是现代的人,而是古人啊!”相见之后,握手相对而哭,然后说平生之事,说了一个多月也不觉厌倦。 当时巢谷已经七十三岁了,瘦而多病,已经不是当日的那个元修了。他还要去海南见子瞻,我同情他年老多病,劝止他说:“你虽然一番好意,但是从这里到子瞻那里数千里,还要过海,不是老人能做到的。”他说:“我自认为还不会马上死,你别拦我。”留不住他,再看看他包里,只有数十钱了。我虽然也很穷,还是凑了点钱给他作为路费。船到了新会,有个南蛮奴隶偷了他的包逃跑,在新州被抓获,巢谷跟着他到了新洲,很快就病死了。我听说后,痛哭失声,埋怨他不听我的话,然而也对他不采纳我的意见而实现自己的心愿感到惊异。以前赵襄子被困于晋阳,智伯率领魏,韩军队用决堤放水的方法围困他。 城内水深到要把锅吊起来才可以生火,彼此交换孩子来煮了吃。群臣都散慢了,只有高恭没有忘记礼数。后来赵襄子采用了张孟谈的计策解了三国的围困,论功行赏时,高恭排在首位。张孟谈说:“晋阳之难,高恭没有一点功劳,为什么以他为先?”襄子说:“因为当时大臣们都散慢了,只有他没有忘记君臣之礼,所以我把他排在首位。”巢谷对朋友的义气,实在比得上高恭,只可惜他没碰上襄子,而只是遇到了存宝和我们兄弟。 我住在南方,和蛮夷住在这里,大概也要死在这里了。虽然知道他的贤德,但我还能用什么方法来传扬他的事迹呢?我听说他有个儿子叫巢蒙,在泾原军中,所以只能为他立传,改天交给巢蒙。

刷机包里“com.qualcomm.qti.services.secureui.apk“ 是什么用途


“ 您好,三星官网没有提供刷机软件。由于刷机存在风险,如因自行刷机后导致的手机问题,还有可能会影响包修,因此我们不建议您自行刷机。
若手机因系统故障无法正常使用或自行刷机后导致手机出现问题,建议您将机器送到三星售后服务中心,由工程师帮助检查处理。“
-pring