Duncan's Blog


  • menu.主页

  • menu.分类

  • menu.关于

  • menu.归档

  • menu.标签
Duncan's Blog

Obama-最美好的时代尚未到来

Veröffentlicht am 2018-01-21

奥巴马专题:


Tonight, more than 200 years after a former colony won the right to determine its own destiny, the task of perfecting our union moves forward.
两百多年前,美国人民在这块曾经的殖民地上赢得了自己的命运,今夜,我们向实现完美联邦的目标又迈进了一步。

OBAMA: It moves forward because of you. It moves forward because you reaffirmed the spirit that has triumphed over war and depression, the spirit that has lifted this country from the depths of despair to the great heights of hope, the belief that while each of us will pursue our own individual dreams, we are an American family and we rise or fall together as one nation and as one people.
奥巴马:这一步是因为你们,这一步是因为你们证明了,克服战争和萧条的那种精神仍在,那份把我们国家从绝望的深渊带向希望之巅的精神,坚信我们每个人都可以追逐自己的梦想。美国同胞血浓于水,作为一个国家和民族,我们共起落,同荣辱。

Tonight, in this election, you, the American people, reminded us that while our road has been hard, while our journey has been long, we have picked ourselves up, we have fought our way back, and we know in our hearts that for the United States of America the best is yet to come.
今晚,在这次选举中,你们,美国人民,提醒了我们尽管路程艰辛、路程漫长,我们仍能振作精神,奋起反击,我们心中坚信,最好的时代,还在等着美利坚。

OBAMA: I want to thank every American who participated in this election…
奥巴马:我想感谢每一位亲身参与大选的美国人。

… whether you voted for the very first time or waited in line for a very long time.
无论这是你的第一次投票或是在队伍中等待了很久。

By the way, we have to fix that.
顺便说一句,这个问题真是亟待解决。

Whether you pounded the pavement or picked up the phone…
无论你是步行前往,还是拿起电话

… whether you held an Obama sign or a Romney sign, you made your voice heard and you made a difference.
无论你举的牌子上写的是奥巴马还是罗姆尼,你都发出了你自己的声音,你也一样,创造了不同。

I just spoke with Governor Romney and I congratulated him and Paul Ryan on a hard-fought campaign.
我刚刚和罗姆尼州长通了电话,向他和保罗·瑞安,就这场艰难的战役表示了我的祝贺。

We may have battled fiercely, but it’s only because we love this country deeply and we care so strongly about its future. From George to Lenore to their son Mitt, the Romney family has chosen to give back to America through public service and that is the legacy that we honor and applaud tonight.
双方的选战或许惨烈,但这正是因为我们如此深爱这个国家。如此关心它的未来,从乔治到兰诺夫妇,再到他们的儿子米特,罗姆尼一家选择通过献身公务来回报美国。今晚,我们向这一份宝贵遗产献上尊敬和掌声。

In the weeks ahead, I also look forward to sitting down with Governor Romney to talk about where we can work together to move this country forward.
在未来的几个星期,我还希望能和罗姆尼州长坐下来讨论在哪些方面,我们可以共同努力,推动这个国家向前。

I want to thank my friend and partner of the last four years, America’s happy warrior, the best vice president anybody could ever hope for, Joe Biden.
我想谢谢我的朋友,我过去四年的搭档。美国的快乐战士,乔·拜登能有他做副总统,夫复何求。

OBAMA: And I wouldn’t be the man I am today without the woman who agreed to marry me 20 years ago.
奥巴马:另外,如果没有那位20年前同意嫁给我的女人,我今天也不可能站在这里。

Let me say this publicly: Michelle, I have never loved you more. I have never been prouder to watch the rest of America fall in love with you, too, as our nation’s first lady.
让我告诉所有人吧,米歇尔,我对你的爱是如此深切,我目睹着我之外的美国人爱上你,我对你作为美国第一夫人感到的骄傲,也是如此地深切。

Sasha and Malia, before our very eyes you’re growing up to become two strong, smart beautiful young women, just like your mom.
萨沙和玛利亚,就在我们的注视下,你们已经成长为两位坚强、智慧、美丽的年轻女士,就像你们的妈妈一样。

OBAMA: And I’m so proud of you guys. But I will say that for now one dog’s probably enough.
奥巴马:我真的为你们骄傲,不过我还是要说,就现在看,一条狗应该已经够了。

To the best campaign team and volunteers in the history of politics…
至政治史上最好的竞选团队和志愿者们

The best. The best ever. Some of you were new this time around, and some of you have been at my side since the very beginning.
你们是最好的,最最好的。你们中有些人是新加入的,有些人从一开始就与我们共同进退。
(APPLAUSE)
(掌声)

But all of you are family. No matter what you do or where you go from here, you will carry the memory of the history we made together and you will have the life-long appreciation of a grateful president. Thank you for believing all the way, through every hill, through every valley.
但你们都是我的家人,无论你是做什么的,以后还要做什么,你们都会带上这段我们的共同创造的历史,以及这位感恩的总统对你们一辈子的感激。谢谢你们的一路坚信,陪我翻过每座丘陵,穿越每座山谷。

You lifted me up the whole way and I will always be grateful for everything that you’ve done and all the incredible work that you put in.
一路走来,多亏你们的辅佐。我会永远为你们所付出的一切和所有卓越之至的工作而心怀感激。

I know that political campaigns can sometimes seem small, even silly. And that provides plenty of fodder for the cynics that tell us that politics is nothing more than a contest of egos or the domain of special interests. But if you ever get the chance to talk to folks who turned out at our rallies and crowded along a rope line in a high school gym, or saw folks working late in a campaign office in some tiny county far away from home, you’ll discover something else.
我知道有时候政治竞选看起来渺小甚至愚蠢,这为愤世嫉俗的人提供了许多素材,他们告诉我们政治不过是自负驱动的比赛,或是为特殊利益集团服务的猴戏。但如果你曾经同参加过我们的集会的普通人,或是在高中体育馆围线外排队的人们交谈过,或是看到在远离家乡的小郡县竞选办公室工作到很晚的人们,你一定会有新的认识。

OBAMA: You’ll hear the determination in the voice of a young field organizer who’s working his way through college and wants to make sure every child has that same opportunity.
奥巴马:你会听到一位半工半读的年轻人现场活动组织者声音中的坚定,想要让每一个孩子都和他有一样的机会。
(APPLAUSE)
(掌声)

You’ll hear the pride in the voice of a volunteer who’s going door to door because her brother was finally hired when the local auto plant added another shift.
你会听到一名志愿者声音中的骄傲,她挨家挨户地告诉每一个人她的哥哥终于有了工作,因为当地的汽车公司增加了一个轮班。

You’ll hear the deep patriotism in the voice of a military spouse whose working the phones late at night to make sure that no one who fights for this country ever has to fight for a job or a roof over their head when they come home.
你会听到一位军嫂声音中深切的爱国主义情怀,她深夜也不放下电话,就是为了要让每一位保家卫国的战士不用在回家后,为了一份工作一片屋檐,苦苦求而不得。
(APPLAUSE)
(掌声)

That’s why we do this. That’s what politics can be. That’s why elections matter. It’s not small, it’s big. It’s important. Democracy in a nation of 300 million can be noisy and messy and complicated. We have our own opinions. Each of us has deeply held beliefs. And when we go through tough times, when we make big decisions as a country, it necessarily stirs passions, stirs up controversy.
这就是我们做这些的原因。这是政治可能的样子,这就是为什么选举是重要的,它并不渺小,它是大事,很重要的大事。有三亿人口的国家,民主会显得喧哗、混乱、复杂,我们有自己的观点,每个人都有自己坚定的信仰。当面对困难的时期,当我们的国家需要作重大的决定时,它必然会激发热情,也会掀起争议。

That won’t change after tonight, and it shouldn’t. These arguments we have are a mark of our liberty. We can never forget that as we speak people in distant nations are risking their lives right now just for a chance to argue about the issues that matter, the chance to cast their ballots like we did today.
这些在今晚之后都不会改变,也不应该被改变。这些争论是我们自由的印记,我们永远不能忘记,就在此时此刻,在一些遥远的国家,人民正在冒着生命的危险,只为了能有讨论那些重要话题的机会,为了能有像我们今天这样投出自己一票的机会。
(APPLAUSE)
(掌声)

But despite all our differences, most of us share certain hopes for America’s future. We want our kids to grow up in a country where they have access to the best schools and the best teachers.
尽管我们有不同,我们中的大多数,对美国的未来怀有一样的希望。我们希望自己的孩子成长在这样一个国家,他们能去到最好的学校,有最好的老师。

A country that lives up to its legacy as the global leader in technology and discovery and innovation, with all the good jobs and new businesses that follow.
它不会辜负前人留下的遗产,继续成为全球科技、探索、创新的领导者,有好的工作,新的产业随之而来。

OBAMA: We want our children to live in an America that isn’t burdened by debt, that isn’t weakened by inequality, that isn’t threatened by the destructive power of a warming planet.
奥巴马:我们希望自己孩子成长的美国不会被债务负累,不会因不平等有所削弱,也不会被地球变暖而带来的危害所威胁。
(APPLAUSE)
(掌声)

We want to pass on a country that’s safe and respected and admired around the world, a nation that is defended by the strongest military on earth and the best troops this - this world has ever known.
我们想要传承的,是一个安全、受全球尊敬和爱戴的国家。我们想要传承的,是一个由世界最强军事力量保卫,拥有最好的军队的国家。

But also a country that moves with confidence beyond this time of war, to shape a peace that is built on the promise of freedom and dignity for every human being. We believe in a generous America, in a compassionate America, in a tolerant America, open to the dreams of an immigrant’s daughter who studies in our schools and pledges to our flag.
同时,也是一个自信前行的国家,走出战争的阴霾,塑造和平景象,保障每个人的自由与尊严,我们相信美国是一个慷慨大度的国家,一个悲天悯人的国家,更是一个海纳百川的国家。我们要接纳在我国学习并对我们的国旗宣誓满怀梦想的移民。

To the young boy on the south side of Chicago who sees a life beyond the nearest street corner.
也要接纳,身处芝加哥南部市井之中却能志存高远的男孩。

To the furniture worker’s child in North Carolina who wants to become a doctor or a scientist, an engineer or an entrepreneur, a diplomat or even a president - that’s the future we hope for. That’s the vision we share. That’s where we need to go - forward.
还要接纳北卡州家具工人的孩子,他们梦想着成为医生、科学家、工程师、企业家、外交官,甚至是总统——那正是我们所期望的未来。是我们共同的愿景,是我们的目标——前进。

That’s where we need to go.
那是我们的目标。

Now, we will disagree, sometimes fiercely, about how to get there. As it has for more than two centuries, progress will come in fits and starts. It’s not always a straight line. It’s not always a smooth path.
对于如何实现这一目标我们可能会意见向左,有时分歧很大。两个多世纪以来,一直如此,我们总会断断续续地取得进步。前进的路线总有曲折,不会一直是平坦通途。

By itself, the recognition that we have common hopes and dreams won’t end all the gridlock or solve all our problems or substitute for the painstaking work of building consensus and making the difficult compromises needed to move this country forward. But that common bond is where we must begin. Our economy is recovering. A decade of war is ending. A long campaign is now over.
认识到我们拥有共同的希望和梦想,单靠这一点无法终结所有的政治僵局或解决我们所有的问题,即使建立共识,作出推动这个国家向前所必要的艰难妥协,这些艰辛的工作也无法得以替代。但我们必须以这一共同纽带为起点。我们的经济正在复苏,为期十年的战争已近尾声,一场漫长的竞选现已结束。
(APPLAUSE)
(掌声)

And whether I earned your vote or not, I have listened to you, I have learned from you, and you’ve made me a better president. And with your stories and your struggles, I return to the White House more determined and more inspired than ever about the work there is to do and the future that lies ahead.
无论我是否赢得了你的选票,我倾听了你的呼声,从你身上得到了教益,你是我成长为更优秀的总统。带着你们的故事和奋斗史,我回到白宫时,对面临的任务和未来,会更为坚定、更有激情。

Tonight you voted for action, not politics as usual.
今晚,你们投票换来的将会是积极的行动,而不是以往那样的政治游戏。

You elected us to focus on your jobs, not ours. And in the coming weeks and months, I am looking forward to reaching out and working with leaders of both parties to meet the challenges we can only solve together. Reducing our deficit. Reforming our tax code. Fixing our immigration system. Freeing ourselves from foreign oil. We’ve got more work to do.
你们选择了我们,是让我们关注你们的就业, 而非我们自己的官位。在接下来的数周、数月中,我期待着与两党领袖进行接触与合作,共同应对我们必须携手攻克的难关。降低赤字,改革税法,完善移民体系,摆脱对进口石油的依赖,我们还有更多的工作要完成。
(APPLAUSE)
(掌声)

OBAMA: But that doesn’t mean your work is done. The role of citizens in our Democracy does not end with your vote. America’s never been about what can be done for us. It’s about what can be done by us together through the hard and frustrating, but necessary work of self-government. That’s the principle we were founded on.
奥巴马:但这并不意味着你们的任务已经结束,公民在我们的民主体系中所扮演的角色,并不止于投票。美利坚的意义并不在于别人能为我们做什么,而是在我们能一起做什么。而这依靠的就是公民自治,这虽然困难而又往往令人灰心,但却是不可或缺的。

This country has more wealth than any nation, but that’s not what makes us rich. We have the most powerful military in history, but that’s not what makes us strong. Our university, our culture are all the envy of the world, but that’s not what keeps the world coming to our shores.
这是我们的建国理念,我们国家的财富多于其他任何国家,但我们的富有并不源于此,我们有史上最强的军事力量,但这并不是我们力量的源头。我们的大学,我们的文化,为世界所歆羡,可这并非吸引各国人民前来我国的根源。

What makes America exceptional are the bonds that hold together the most diverse nation on earth. The belief that our destiny is shared; that this country only works when we accept certain obligations to one another and to future generations. The freedom which so many Americans have fought for and died for come with responsibilities as well as rights. And among those are love and charity and duty and patriotism. That’s what makes America great.
真正让美国与众不同的,是将这个地球上最多元化的国家的人民团结到一起的那些纽带。是我们共命运的信念,是只有当我们肩负某些对彼此以及对后代的责任美国才能走下去的信念,是无数的美国人前赴后继为之奋斗的自由──它既赋予了我们权利,也给我们带来了责任;是爱、慈善、义务和爱国。正是这些让美国变得伟大。

I am hopeful tonight because I’ve seen the spirit at work in America. I’ve seen it in the family business whose owners would rather cut their own pay than lay off their neighbors, and in the workers who would rather cut back their hours than see a friend lose a job. I’ve seen it in the soldiers who reenlist after losing a limb and in those SEALs who charged up the stairs into darkness and danger because they knew there was a buddy behind them watching their back.
今晚,我满怀希望,因为我已经看到美国精神正在得以发扬。我看到有些家族企业,所有者宁可减少自己的薪酬也不愿让邻居丢掉工作;我看到有些工人宁愿缩减自己的工时也不愿看到朋友没有活干;我看到有些士兵在失去一条腿或胳膊之后又选择再次入伍;我看到海豹突击队员不避危险冲上楼梯、冲入黑暗,因为他们知道有一个兄弟在做他的后盾。
(APPLAUSE)
(掌声)

I’ve seen it on the shores of New Jersey and New York, where leaders from every party and level of government have swept aside their differences to help a community rebuild from the wreckage of a terrible storm. And I saw just the other day, in Mentor, Ohio, where a father told the story of his 8-year-old daughter, whose long battle with leukemia nearly cost their family everything had it not been for health care reform passing just a few months before the insurance company was about to stop paying for her care.
在新泽西和纽约的海岸,我也看到了美国精神。每一个政党和各级政府的领导者都捐弃分歧,为在骇人风暴过后的废墟上重建社区各尽己力。就在不久前的一天,在俄亥俄的门托,我看到一位父亲在讲述他8岁女儿的故事。这个女孩与白血病进行了长期的斗争,如果不是因为几个月前通过的医改法案,保险公司就会停止支付医疗费用,他们的家庭就将失去一切。

I had an opportunity to not just talk to the father, but meet this incredible daughter of his. And when he spoke to the crowd listening to that father’s story, every parent in that room had tears in their eyes, because we knew that little girl could be our own. And I know that every American wants her future to be just as bright. That’s who we are. That’s the country I’m so proud to lead as your president.
我曾有机会与这位父亲攀谈,不仅如此,我还见到了他的女儿,这个非常了不起的小姑娘。当这位父亲向倾听他的故事的人讲述时,每一位在场的父母的眼里都含着泪水,因为我们知道,我们自己的孩子也有可能遇到这种状况。而且我知道,每一位美国人都希望这位小女孩的未来能像所有人的未来一样光明。这就是美国人,这就是美国,我为自己能够成为这个国家的总统、带领这个国家前行感到无比光荣。

And tonight, despite all the hardship we’ve been through, despite all the frustrations of Washington, I’ve never been more hopeful about our future. I have never been more hopeful about America. And I ask you to sustain that hope. I’m not talking about blind optimism, the kind of hope that just ignores the enormity of the tasks ahead or the roadblocks that stand in our path. I’m not talking about the wishful idealism that allows us to just sit on the sidelines or shirk from a fight.
今晚,尽管我们遭遇了很多困难,尽管华盛顿有诸多不尽人意之处,我仍从未像现在这样对未来充满希望。我从未像现在这样对美国充满希望。我请大家也保持这样的希望。我所说的并非盲目的乐观主义,不是那种看不到眼前的任务有多么艰巨、看不到前行的路上有什么样的障碍的希望;我所说的并非作壁上观或是临战退缩的一厢情愿的理想主义。

I have always believed that hope is that stubborn thing inside us that insists, despite all the evidence to the contrary, that something better awaits us so long as we have the courage to keep reaching, to keep working, to keep fighting.
我一直相信,所谓希望就是我们内心倔强地坚持的力量,相信不管有多少相反的证据,都要相信有更好的东西在等着我们,只要我们有勇气不断前行、不懈工作、不停战斗。

America, I believe we can build on the progress we’ve made and continue to fight for new jobs and new opportunity and new security for the middle class. I believe we can keep the promise of our founders, the idea that if you’re willing to work hard, it doesn’t matter who you are or where you come from or what you look like or where you love. It doesn’t matter whether you’re black or white or Hispanic or Asian or Native American or young or old or rich or poor, able, disabled, gay or straight, you can make it here in America if you’re willing to try.
国民们,我相信我们有能力在已经取得的进步的基础上再进一步,继续为了给中产阶级创造新的工作、新的机遇、新的保障而战斗。我相信我们有能力信守开国者们许下的诺言,信守这样一种理念,那就是不管你是谁,不管你来自哪里,不管你长相如何,不管你爱着哪个地方,你所需要做的就是努力工作。不管你的肤色是黑是白,不管你是拉美裔、亚裔还是美国原住民,不管你年轻还是年老,富有还是贫穷,身体健全或是残障,同性恋还是异性恋,只要你愿意努力,就能够在美国大有作为。

I believe we can seize this future together because we are not as divided as our politics suggests. We’re not as cynical as the pundits believe. We are greater than the sum of our individual ambitions, and we remain more than a collection of red states and blue states. We are and forever will be the United States of America.
我相信我们有能力共同握住这样的未来,因为美国人民并不像政界那么严重分歧。美国人民不像某些饱学之士所认为的那样愤世嫉俗。美国的抱负并不是每一个美国人的抱负的简单加总,美国也不是红州和蓝州的简单联合。我们是美利坚合众国,我们将永远是美利坚合众国。

And together with your help and God’s grace we will continue our journey forward and remind the world just why it is that we live in the greatest nation on Earth.
有你们的帮助,有上帝的仁慈,我们将继续携手前行,让全世界知道我们生活在全球最伟大的国度的原因到底是什么。

Thank you, America. God bless you. God bless these United States.
谢谢你,国民们,上帝保佑你们,上帝保佑美国。

Duncan's Blog

林肯葛底斯堡演讲

Veröffentlicht am 2018-01-19 | in Life

Gettysburg Address 林肯在葛底斯堡的演说
(Delivered on the 19th Day of November, 1863 Cemetery Hill, Gettysburg, Pennsylvania )

Fourscore and seven years ago, our fathers brought forth upon this continent a new Nation, conceived in Liberty, and dedicated to the proposition that all men are created equal. Now, we are engaged in a great Civil War, testing whether that Nation, or any nation so conceived and so dedicated, can long endure. We are met on a great battlefield of that war. We have come to dedicate a portion of that field as a final resting-place for those who here gave their lives that Nation might live. It is altogether fitting and proper that we should do this.
But, in a larger sense, we cannot dedicate, we cannot consecrate, we cannot hallow this ground. The brave men, living and dead, who struggled here, have consecrated it far above our poor power to add or detract. The world will little note nor long remember what we say here, but it can never forget what they did here. It is for us, the living, rather to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced. It is rather for us to be here dedicated to the great task remaining before us; that from these honored dead, we take increased devotion to that cause for which they gave the last full measure of devotion; that we here highly resolve that these dead shall not have died in vain, that this Nation, under GOD, shall have a new birth of freedom; and that government of the People by the People and for the People shall not perish from the earth.

87年前,我们的先辈们在这个大陆上创立了一个新国家,它孕育于自由之中,奉行一切人生来平等的原则。现在我们正从事一场伟大的内战,以考验这个国家,或者任何一个孕育于自由和奉行上述原则的国家是否能够长久存在下去。我们在这场战争中的一个伟大战场上集会。烈士们为使这个国家能够生存下去而献出了自己的生命,我们来到这里,是要把这个战场的一部分奉献给他们作为最后安息之所。我们这样做是完全应该而且是非常恰当的。
但是,从更广泛的意义上来说,这块土地我们不能够奉献,不能够圣化,不能够神化。那些曾在这里战斗过的勇士们,活着的和去世的,已经把这块土地圣化了,这远不是我们微薄的力量所能增减的。我们今天在这里所说的话,全世界不大会注意,也不会长久地记住,但勇士们在这里所做过的事,全世界却永远不会忘记。毋宁说,倒是我们这些还活着的人,应该在这里把自己奉献于勇士们已经如此崇高地向前推进但尚未完成的事业。倒是我们应该在这里把自己奉献于仍然留在我们面前的伟大任务—我们要从这些光荣的死者身上汲取更多的献身精神,来完成他们已经完全彻底为之献身的事业;我们要在这里下定最大的决心,不让这些死者白白牺牲;我们要使国家在上帝福佑下得到自由的新生,要使这个民有、民治、民享的政府永世长存。

Duncan's Blog

Steve Jobs In Stanford University

Veröffentlicht am 2018-01-19 | in Life

Thank you.
I’m honored to be with you today for your commencement from one of the finest universities in the world. Truth be told, I never graduated from college, and this is the closest I’ve ever gotten to a college graduation. Today, I want to tell you three stories from my life. That’s it. No big deal. Just three stories.

The first story is about connecting the dots. I dropped out of Reed College after the first six months, but then stayed around as a drop-in for another 18 months or so before I really quit. So why did I drop out?

It started before I was born. My biological mother was a young, unwed graduate student, and she decided to put me up for adoption. She felt very strongly that I should be adopted by college graduates, so everything was all set for me to be adopted at birth by a lawyer and his wife — except that when I popped out they decided at the last minute that they really wanted a girl.

So my parents, who were on a waiting list, got a call in the middle of the night asking, “We’ve got an unexpected baby boy; do you want him?” They said, “Of course.” My biological mother found out later that my mother had never graduated from college and that my father had never graduated from high school. She refused to sign the final adoption papers. She only relented a few months later when my parents promised that I would go to college. This was the start in my life.

And 17 years later I did go to college. But I naively chose a college that was almost as expensive as Stanford, and all of my working-class parents’ savings were being spent on my college tuition. After six months, I couldn’t see the value in it. I had no idea what I wanted to do with my life and no idea how college was going to help me figure it out. And here I was spending all of the money my parents had saved their entire life.

So I decided to drop out and trust that it would all work out okay. It was pretty scary at the time, but looking back it was one of the best decisions I ever made. The minute I dropped out I could stop taking the required classes that didn’t interest me, and begin dropping in on the ones that looked far more interesting.

It wasn’t all romantic. I didn’t have a dorm room, so I slept on the floor in friends’ rooms. I returned coke bottles for the five cent deposits to buy food with, and I would walk the seven miles across town every Sunday night to get one good meal a week at the Hare Krishna temple. I loved it. And much of what I stumbled into by following my curiosity and intuition turned out to be priceless later on. Let me give you one example:

Reed College at that time offered perhaps the best calligraphy instruction in the country. Throughout the campus every poster, every label on every drawer, was beautifully hand calligraphed. Because I had dropped out and didn’t have to take the normal classes, I decided to take a calligraphy class to learn how to do this. I learned about serif and san serif typefaces, about varying the amount of space between different letter combinations, about what makes great typography great. It was beautiful, historical, artistically subtle in a way that science can’t capture, and I found it fascinating.

None of this had even a hope of any practical application in my life. But ten years later, when we were designing the first Macintosh computer, it all came back to me. And we designed it all into the Mac. It was the first computer with beautiful typography. If I had never dropped in on that single course in college, the “Mac” would have never had multiple typefaces or proportionally spaced fonts. And since Windows just copied the Mac, it’s likely that no personal computer would have them. If I had never dropped out, I would have never dropped in on that calligraphy class, and personal computers might not have the wonderful typography that they do. Of course it was impossible to connect the dots looking forward when I was in college. But it was very, very clear looking backwards 10 years later.

Again, you can’t connect the dots looking forward; you can only connect them looking backwards. So you have to trust that the dots will somehow connect in your future. You have to trust in something — your gut, destiny, life, karma, whatever — because believing that the dots will connect down the road will give you the confidence to follow your heart, even when it leads you off the well-worn path, and that will make all the difference.

My second story is about love and loss.

I was lucky — I found what I loved to do early in life. Woz1 and I started Apple in my parents’ garage when I was 20. We worked hard, and in 10 years Apple had grown from just the two of us in a garage into a two billion dollar company with over 4000 employees. We’d just released our finest creation — the Macintosh — a year earlier, and I had just turned 30.

And then I got fired. How can you get fired from a company you started? Well, as Apple grew we hired someone who I thought was very talented to run the company with me, and for the first year or so things went well. But then our visions of the future began to diverge and eventually we had a falling out. When we did, our Board of Directors sided with him. And so at 30, I was out. And very publicly out. What had been the focus of my entire adult life was gone, and it was devastating.

I really didn’t know what to do for a few months. I felt that I had let the previous generation of entrepreneurs down — that I had dropped the baton as it was being passed to me. I met with David Packard and Bob Noyce and tried to apologize for screwing up so badly. I was a very public failure, and I even thought about running away from the valley. But something slowly began to dawn on me: I still loved what I did. The turn of events at Apple had not changed that one bit. I had been rejected, but I was still in love. And so I decided to start over.

I didn’t see it then, but it turned out that getting fired from Apple was the best thing that could have ever happened to me. The heaviness of being successful was replaced by the lightness of being a beginner again, less sure about everything. It freed me to enter one of the most creative periods of my life.

During the next five years, I started a company named NeXT, another company named Pixar, and fell in love with an amazing woman who would become my wife. Pixar went on to create the world’s first computer-animated feature film, Toy Story, and is now the most successful animation studio in the world. In a remarkable turn of events, Apple bought NeXT, and I retuned to Apple, and the technology we developed at NeXT is at the heart of Apple’s current renaissance. And Laurene and I have a wonderful family together.

I’m pretty sure none of this would have happened if I hadn’t been fired from Apple. It was awful tasting medicine, but I guess the patient needed it. Sometime life — Sometimes life going to hit you in the head with a brick. Don’t lose faith. I’m convinced that the only thing that kept me going was that I loved what I did. You’ve got to find what you love.

And that is as true for your work as it is for your lovers. Your work is going to fill a large part of your life, and the only way to be truly satisfied is to do what you believe is great work. And the only way to do great work is to love what you do. If you haven’t found it yet, keep looking — and don’t settle. As with all matters of the heart, you’ll know when you find it. And like any great relationship, it just gets better and better as the years roll on. So keep looking — don’t settle.

My third story is about death.

When I was 17, I read a quote that went something like: “If you live each day as if it was your last, someday you’ll most certainly be right.” It made an impression on me, and since then, for the past 33 years, I’ve looked in the mirror every morning and asked myself: “If today were the last day of my life, would I want to do what I am about to do today?” And whenever the answer has been “No” for too many days in a row, I know I need to change something.

Remembering that I’ll be dead soon is the most important tool I’ve ever encountered to help me make the big choices in life. Because almost everything — all external expectations, all pride, all fear of embarrassment or failure — these things just fall away in the face of death, leaving only what is truly important. Remembering that you are going to die is the best way I know to avoid the trap of thinking you have something to lose. You are already naked. There is no reason not to follow your heart.

About a year ago I was diagnosed with cancer. I had a scan at 7:30 in the morning, and it clearly showed a tumor on my pancreas. I didn’t even know what a pancreas was. The doctors told me this was almost certainly a type of cancer that is incurable, and that I should expect to live no longer than three to six months. My doctor advised me to go home and get my affairs in order, which is doctor’s code for “prepare to die.” It means to try and tell your kids everything you thought you’d have the next 10 years to tell them in just a few months. It means to make sure everything is buttoned up so that it will be as easy as possible for your family. It means to say your goodbyes.

I lived with that diagnosis all day. Later that evening I had a biopsy, where they stuck an endoscope down my throat, through my stomach into my intestines, put a needle into my pancreas and got a few cells from the tumor. I was sedated, but my wife, who was there, told me that when they viewed the cells under a microscope the doctors started crying because it turned out to be a very rare form of pancreatic cancer that is curable with surgery. I had the surgery and, thankfully, I’m fine now.

This was the closest I’ve been to facing death, and I hope it’s the closest I get for a few more decades. Having lived through it, I can now say this to you with a bit more certainty than when death was a useful but purely intellectual concept: No one wants to die.

Even people who want to go to heaven don’t want to die to get there. And yet death is the destination we all share. No one has ever escaped it. And that is as it should be, because Death is very likely the single best invention of Life. It’s Life’s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it’s quite true.

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma — which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.

When I was young, there was an amazing publication called The Whole Earth Catalog, which was one of the “bibles” of my generation. It was created by a fellow named Stewart Brand not far from here in Menlo Park, and he brought it to life with his poetic touch. This was in the late 60s, before personal computers and desktop publishing, so it was all made with typewriters, scissors, and Polaroid cameras. It was sort of like Google in paperback form, 35 years before Google came along. It was idealistic, overflowing with neat tools and great notions.

Stewart and his team put out several issues of The Whole Earth Catalog, and then when it had run its course, they put out a final issue. It was the mid-1970s, and I was your age. On the back cover of their final issue was a photograph of an early morning country road, the kind you might find yourself hitchhiking on if you were so adventurous. Beneath it were the words: “Stay Hungry. Stay Foolish.” It was their farewell message as they signed off. Stay Hungry. Stay Foolish. And I’ve always wished that for myself. And now, as you graduate to begin anew, I wish that for you.

Stay Hungry. Stay Foolish.

Thank you all very much.

Duncan's Blog

林肯第二次就职演说

Veröffentlicht am 2018-01-19 | in Life

Fellow-Countrymen:

  At this second appearing to take the oath of the Presidential office there is less occasion for an extended address than there was at the first. Then a statement somewhat in detail of a course to be pursued seemed fitting and proper. Now, at the expiration of four years, during which public declarations have been constantly called forth on every point and phase of the great contest which still absorbs the attention and engrosses the energies of the nation, little that is new could be presented. The progress of our arms, upon which all else chiefly depends, is as well known to the public as to myself, and it is, I trust, reasonably satisfactory and encouraging to all. With high hope for the future, no prediction in regard to it is ventured.

  On the occasion corresponding to this, four years ago all thoughts were anxiously directed to an impending civil war. All dreaded it, all sought to avert it. While the inaugural address was being delivered from this place, devoted altogether to saving the Union without war, insurgent agents were in the city seeking to destroy it without war-seeking to dissolve the Union and divide effects by negotiation. Both parties deprecated war, but one of them would make war rather than let the nation survive, and the other would accept war rather than let it perish, and the war came.

  One-eighth of the whole population were colored slaves, not distributed generally over the Union, but localized in the southern part of it. These slaves constituted a peculiar and powerful interest. All knew that this interest was somehow the cause of the war. To strengthen, perpetuate, and extend this interest was the object for which the insurgents would rend the Union even by war, while the Government claimed no right to do more than to restrict the territorial enlargement of it. Neither party expected for the war the magnitude or the duration which it has already attained. Neither anticipated that the cause of the conflict might cease with or even before the conflict itself should cease. Each looked for an easier triumph, and a result less fundamental and astounding. Both read the same Bible and pray to the same God, and each invokes His aid against the other. It may seem strange that any men should dare to ask a just God’s assistance in wringing their bread from the sweat of other men’s faces, but let us judge not, that we be not judged. The prayers of both could not be answered. That of neither has been answered fully. The Almighty has His own purposes. “Woe unto the world because of offenses; for it must needs be that offenses come, but woe to that man by whom the offense cometh.”[1] If we shall suppose that American slavery is one of those offenses which, in the providence of God, must needs come, but which, having continued through His appointed time, He now wills to remove, and that He gives to both North and South this terrible war as the woe due to those by whom the offense came, shall we discern therein any departure from those divine attributes which the believers in a living God always ascribe to Him? Fondly do we hope, fervently do we pray, that this mighty scourge of war may speedily pass away. Yet, if God wills that it continue until all the wealth piled by the bondsman’s two hundred and fifty years of unrequited toil shall be sunk, and until every drop of blood drawn with the lash shall be paid by another drawn with the sword, as was said three thousand years ago, so still it must be said “the judgments of the Lord are true and righteous altogether.”[2]

  With malice toward none, with charity for all, with firmness in the right as God gives us to see the right, let us strive on to finish the work we are in, to bind up the nation’s wounds, to care for him who shall have borne the battle and for his widow and his orphan, to do all which may achieve and cherish a just and lasting peace among ourselves and with all nations.

同胞们:

  这是我第二次宣誓就任总统,所以不太适合像第一次就职那样作长篇的演讲。初次就职时比较适合较为详细地叙述我们要追求的道路。而现在,我的四年任期刚刚结束。在这四年里,对于这场旷日持久、举国瞩目的斗争的方方面面,我一直不断地发表公开宣言,所以也没有什么新的内容要讲。军事力量是决定一切的关键,这方面的进展,大家跟我一样熟知,并且我相信,大家也对此感到满意和鼓舞。既然我们对未来抱有很大希望,那么在军事方面也就无须再做什么预言。

  四年前我初次就职之时,所有的想法和忧虑都集中在即将爆发的内战问题上。大家害怕内战,都设法避免它的发生。当时我在此发表的就职演说,全部致力于不战而拯救联邦,然而,这座城市里的造反派却企图通过主张不战而摧毁联邦,他们企图通过妥协和谈判来瓦解联邦,瓜分这个国家。两方都反对战争,但其中一方宁愿发动战争也不愿联邦存续,而另一方不愿看到联邦解体,所以他们宁肯接受战争,于是内战就爆发了。

  我国八分之一的人口是黑奴,他们并非不是广泛分布于全国各地,而是集中在美国南部。这些黑奴带来了一种特殊而强大的利益。所有人都知道这种利益迟早会成为战争的起因。为了加强、延续和扩展这种利益,造反派不惜发动战争分裂联邦,而政府所做的仅仅是要求将奴隶制限于原来区域,不能再扩张。双方都未曾料到战争会发展到这么大的规模,会持续这么久,也不觉得引起冲突的原因会在冲突本身停止时或者停止前就消失。双方都想轻而易举地得到胜利,也不想执着于一个彻底或让世人震惊的结果。双方读的是同一本圣经,向同一位上帝祷告,都诉求上帝帮助自己战胜对方。看起来很奇怪吧,居然有人敢请求公正的上帝帮助自己去榨取他人的血汗,掠夺他人的劳动成果;但我们还是不要随意鉴定吧,以免我们自己也被人说三道四。双方的祈求上帝不能回应,也没有任何一方得到满意的回应,因为全能的上帝自有他的主张。“苦难降临于世,是因为人犯下了罪过,因为人注定要犯错,然而苦难只降临在那些带来罪过的人身上。”我们如果肯相信奴隶制是那些罪过之一,是按照上帝的旨意降给我们的罪过,而这罪过已经到了上帝指定的期限,上帝现在要让这罪过消失,所以他把这场可怕的战争给予南北双方,他要惩罚那些犯下罪过的人们,那么笃信上帝并把许多神圣的属性赋予上帝的信徒们能说上帝的行为与他的神圣相违背吗?我们满怀着希望,我们热忱地祈祷,愿这战争的鞭笞早日过去。然而,假如上帝要这场战争延续下去,直至两百五十年来利用奴隶的无偿劳动所积聚的财富全部散尽,直至奴隶在皮鞭下流淌的每一滴血都用刀剑下的血来偿还,那么,如同三千年前《圣经》中所说的,“我们仍要称颂上帝的判决是公允合理的。”

  我们对任何人都没有恶意,对所有人都怀有善心,我们坚信上帝赋予了我们明辨是非的能力,让我们努力完成我们正在进行的事业,包扎这个国家的伤痕,关怀每一位战死的烈士和他的妻儿,尽一切力量争取和维护我们国家及各个国家公正且长久的和平.

Duncan's Blog

George Washington - First inaugural address

Veröffentlicht am 2018-01-19 | in Life

Nothing filled me with greater anxieties than that of which the notification was transmitted by your order, and received on the 14th day of the present month.On the one hand, I was summoned by my country, whose voice I can never hear but with veneration and love, from a retreat which I had chosen with the fondest predilection, and, in my flattering hopes, with an immutable decision, as the asylum of my declining years a retreat which was rendered every day more necessary as well as more dear to me by the addition of habit to inclination, and of frequent interruptions in my health to the gradual waste committed on it by time.

On the other hand, the magnitude and difficulty of the trust to which the voice of my country called me, being sufficient to awaken in the wisest and most experienced of her citizens a distrustful scrutiny into his qualifications, could not but overwhelm with despondence one who (inheriting inferior endowments from nature, and unpracticed in the duties of civil administration) ought to be peculiarly conscious of his own deficiencies.In this conflict of emotions all I dare aver is that it has been my faithful study to collect, my duty from a just appreciation of every circumstance by which it might be affected. All I dare hope is that if, in executing this task, I have been too much swayed by a grateful remembrance of former instances, or by an affectionate sensibility to this transcendent proof of the confidence of my fellow citizens, and have thence too little consulted my incapacity as well as disinclination for the weighty and untried cares before me, my error will be palliated by the motives which mislead me,and its consequences be judged by my country with some share of the partiality in which they originated.

Such being the impressions under which I have, in obedience to the public summons, repaired to the present station, it would be peculiarly improper to omit in this first official act my fervent supplications to that Almighty Being who rules over the universe, who presides in the councils of nations, and whose providential aids supply every human defect, that His benediction may consecrate to the liberties and happiness of the people of the United States a Government instituted by themselves for these essential purposes, and may enable every instrument employed in its administration to execute with success the functions allotted to his charge.

In tendering this homage to the Great Author of every public and private good, I assure myself that it expresses your sentiments not less than my own, nor those of my fellow citizens at large less than either. No people can be bound to acknowledge and adore the Invisible Hand which conducts the affairs of men more than those of the United States. Every step by which they have advanced to the character of an independent nation seems to have been distinguished by some token of providential agency; and in the important revolution just accomplished in the system of their united government the tranquil deliberations, along with an humble anticipation of the future blessings which the past seem to presage.These reflections, arising out of the present crisis, have forced themselves too strongly on my mind to be suppressed.

You will join with me, I trust, in thinking that there are none under the influence of which the proceedings of a new and free government can more auspiciously commence. By the article establishing the executive department it is made the duty of the President, “to recommend to your consideration such measures as he shall judge necessary and expedient.”The circumstances under which I now meet you will acquit me from entering into that subject further than to refer to the great constitutional charter under which you are assembled, and which, in defining your powers, designates the objects to which your attention is to be given. It will be more consistent with those circumstances, and far more congenial with the feelings which actuate me, to substitute, in place of a recommendation of particular measures, the tribute that is due to the talents, the rectitude, and the patriotism which adorn the characters selected to devise and adopt them.

In these honorable qualifications I behold the surest pledges that as on one side no local prejudices or attachments, no separate views nor party animosities, will misdirect the comprehensive and equal eye which ought to watch over this great assemblage of communities and interests, so ,on another, that the foundation of our national policy will be laid in the pure and immutable principles of private morality, and the preeminence of free government be exemplified by all the attributes which can win the affections of its citizens and command the respect of the world.I dwell on this prospect with every satisfaction which an ardent love for my country can inspire, since there is no truth more thoroughly established than that there exists in the economy and course of nature an indissoluble union between virtue and happiness; between duty and advantage; between the genuine maxims of an honest and magnanimous policy and the solid rewards of public prosperity and felicity; since we ought to be no a nation that disregards the eternal rules of order and right which Heaven itself has ordained; and since the preservation of the sacred fire of liberty and the destiny of the republican model of government are justly considered, perhaps, as deeply, as finally, staked on the experiment entrusted on the hands of the American people.

在人生沉浮中,没有一件事能比你们于本月14日送达的通知更使我焦虑不安。一方面,国家召唤我出任此职,对于她的召唤,我永远只能肃然敬从;而隐退是我以挚爱心情、满腔希望和坚定的决心选择的暮年归宿,由于爱好和习惯,时感体力不济,愈觉隐退之必要和可贵。且时光流逝,健康渐衰。

另一方面,国家召唤我担负的责任如此重大和艰巨,足以使国内最有才智和经验的人度德量力;而我天资愚钝,又无民政管理的实践,理应倍觉自己能力之不足,因而必然感到难以肩此重任。怀着这种矛盾心情,我唯一敢断言的是,通过正确估计可能产生影响的各种情况来克尽吾职,乃是我忠贞不渝的努力目标。我唯一敢祈望的是,如果我在执行这项任务时因陶醉于往事。或因由衷感激公民们对我的高度信赖,因而受到过多影响,以致在处理从未经历过的大事时,忽视了自己的无能和消极。我的错误将会由于使我误人歧途的各种动机而减轻,而大家在评判错误的后果时,也会适当包涵产生这些动机的偏见。

既然这就是我在遵奉公众召唤就任现职时的感想,那么,在此宣誓就职之际,如不热忱地祈求全能的上帝就极其失当。因为上帝统治着宇宙,主宰着各国政府,它的神助能弥补人类的任何不足。愿上帝赐福,保佑一个为美国人民的自由和幸福而组成的政府,保佑它为这些基本目标而做出奉献。保佑政府的各项行政措施在我负责之下都能成功地发挥作用。

在向公众利益和私人利益的伟大缔造者献上这份崇敬时,我保证这不仅表达了我自己的情感,这些话也同样表达了各位和广大公民的心意。没有人能比美国更坚定不移地承认和崇拜掌管人间事务的上帝。他们在迈向独立国家的进程中,似乎每走一步都有某种天佑的迹象;他们在刚刚完成的联邦政府体制的重大改革中,如果不是因虔诚的感恩而得到某种回报,如果不是谦卑地期待着过去有所预示的赐福的到来,那么,通过众多截然不同的集团的冷静思考和自愿赞同来完成改革,这种方式是不能与大多数政府的组建方式同日而语的。

在目前转折关头,我产生这些想法确实是深有所感而不能自已。我相信大家会和我怀有同感,即除了仰仗上帝的力量,一个新生的自由政府别无他法能一开始就事事顺利。根据设立行政部门的条款,总统有责任对你们提出建议。如衡量权宜必要的判断之类的思路。但在目前与各位见面的这个场合,恕我不能进一步讨论这个问题,而只是提一下伟大的宪法,它使各位今天聚集一堂,它规定了各位的权限,提出了各位应该注意的目标。在这样的场合,更恰当、也更能反映我内心激情的做法。不是提出具体措施,而是称颂将要规划和采纳这些措施的当选者的才能、正直和爱国心。

我从这些高贵品格中看到了最可靠的保证:其一,任何地方偏见或地方感情,任何意见分歧或党派敌视,都不能使我们偏离全局观念和公平观点,即必须维护这个由不同地区和不同利益所组成的大联合;因为,其二,我国政策将会以纯洁而坚定的个人道德原则为基础,而自由政府将会以那赢得民心和全世界尊敬的一切特点而显示其优越性。我对国家的一片热爱之心激励着我满怀喜悦地展望这幅远景,因为根据自然界的构成和发展趋势,在美德与幸福之间,有着密不可分的统一;责任与利益之间,恪守诚实宽厚的政策与获得社会繁荣幸福的硕果之间,因为我们应该同样相信,上帝亲自规定了永恒的秩序和权利法则,它决不可能对无视这些法则的国家仁慈地加以赞许;因为人们理所当然地、满怀觉悟地,也许是最后一次把维护神圣的自由之火和共和制政府的命运,系于美国人所遵命进行的实验上。

Duncan's Blog

后缀树

Veröffentlicht am 2017-09-23 | in Learning

后缀树学习

概念: 后缀树是一种PAT树(检索树),它描述了给定字符串的所要后缀,许多重要的字符串操作都能够在后缀树上快速地实现.

定义: 一个长度为n的字符串s,它的后缀树定义为一棵满足如下条件的树:

  • 1.从根到树叶的路径与s的后缀一一对应.即每条路径唯一代表了s的一个后缀;
  • 每条边都代表一个非空的字符串;
  • 所有内部节点(除根节点)都至少两个子节点.由于并非所有的字符串都存在这样的树,因此s通常使用一个终止符进行填充(通常使用$).

计算最长回文字串

Manacher算法: 用一个辅助数组Len,Len[i表示以字符T[i]为中心的最长回文串最友字符到T[i]的长度.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Manacher算法计算过程
int MANACHER(String str)
{
int mx=0,ans=0,po=0;//mx即为当前计算回文串最右边字符的最大值
for(int i=1;i<=str.len;i++)
{
if(mx>i)
Len[i]=min(mx-i,Len[2*po-i]);//在Len[j]和mx-i中取个小
else
Len[i]=1;//如果i>=mx,要从头开始匹配
while(st[i-Len[i]]==st[i+Len[i]])
Len[i]++;
if(Len[i]+i>mx)//若新计算的回文串右端点位置大于mx,要更新po和mx的值
{
mx=Len[i]+i;
po=i;
}
ans=max(ans,Len[i]);
}
return ans-1;//返回Len[i]中的最大值-1即为原串的最长回文子串额长度
}

Duncan's Blog

RESTful web service

Veröffentlicht am 2017-05-25 | in Note

概念

REST架构就是为了HTTP协议设计的。RESTful web services的核心概念是管理资源。资源是由URIs来表示,客户端使用HTTP当中的’POST, OPTIONS, GET, PUT, DELETE’等方法发送请求到服务器,改变相应的资源状态。

1
2
3
4
5
6
7
8
9
========== =============================================== =============================
HTTP 方法 URL 动作
========== =============================================== ==============================
GET http://[hostname]/todo/api/v1.0/tasks 检索任务列表
GET http://[hostname]/todo/api/v1.0/tasks/[task_id] 检索某个任务
POST http://[hostname]/todo/api/v1.0/tasks 创建新任务
PUT http://[hostname]/todo/api/v1.0/tasks/[task_id] 更新任务
DELETE http://[hostname]/todo/api/v1.0/tasks/[task_id] 删除任务
========== ================================================ =============================

参见该地址

http://www.pythondoc.com/flask-restful/first.html

Duncan's Blog

apoc-introduction

Veröffentlicht am 2017-05-23 | in Learning

安装

1.github下载链接:https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/3.1.2.5
(对应neo-4j版本下载相应的apoc jar包,并将jar包置于neo4j的plugins下.

使用

开发文档

github地址:https://neo4j-contrib.github.io/neo4j-apoc-procedures/

Duncan's Blog

OpenMPILearning

Veröffentlicht am 2017-05-22
Duncan's Blog

springmvc-mybatis

Veröffentlicht am 2016-11-01 | in Note

SpringMVC+Mybatis配置(基于Maven构建,编辑器Intellij)

本文基于原文http://doc.okbase.net/fengshizty/archive/126397.html配置环境。
首先说说几个问题
1.关于Mybatis-Request processing failed; nested exception is org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
数据映射xml文件最好在resources下建立mapper文件夹,并将mapper文件夹也设置为resources格式

2.当在Controller中通过ModelMap返回给视图数据时,如果在jsp页面中使用${}这样的EL语言获取值时,需要在<%@ page contentType=”text/html;charset=UTF-8” language=”java” isELIgnored=”false” %>中添加isELIgnored值为false。

3.如果使用Mybatis自动生成dao、mapping、model层文件时,尤其是mapping xml文件里的路径一定要注意正确,否则会给你的项目调试带来很大的麻烦。

4.原文中使用了SpringJUnit4ClassRunner测试,在完成这个步骤时遇到的问题是,这边测试时,Spring的配置并没有加载好,所以在注入dao层的mapper时报错,所以最后是在整个demo完成时再测试的。测试代码如下:

    import com.alibaba.fastjson.JSON;
    import com.duncan.user.model.UserInfo;
    import com.duncan.user.service.UserService;
    import org.apache.log4j.Logger;
    import org.junit.Test;
    import org.junit.runner.RunWith;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.test.context.ContextConfiguration;
    import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
    import java.util.List;
    /**
     * Created by DuncanZhou on 2016/10/31.
     */
    @RunWith(SpringJUnit4ClassRunner.class)
    @ContextConfiguration(locations = { "classpath:spring.xml",
            "classpath:spring-mybatis.xml" })
    public class TestUserService {
        private static final Logger LOGGER = Logger
                .getLogger(TestUserService.class);
        @Autowired
        private UserService userService;
        @Test
        public void testQueryById1() {
            UserInfo userInfo = userService.getUserById(1);
            LOGGER.info(JSON.toJSON(userInfo));
        }

    //    @Test
    //    public void testQueryAll() {
    //        List<UserInfo> userInfos = userService.getUsers();
    //        LOGGER.info(JSON.toJSON(userInfos));
    //    }

        @Test
        public void testInsert() {
            UserInfo userInfo = new UserInfo();
            userInfo.setName("xiaoming");
            userInfo.setSex("man");
            userInfo.setAge(23);
            userInfo.setPasswd("123");
            int result = userService.insert(userInfo);
            System.out.println(result);
        }
    }

工程目录结构如下

1…67
duncan

duncan

write something useful

70 Artikel
13 Kategorien
18 Tags
RSS
GitHub instagram music zhihu
© 2019 duncan
Erstellt mit Hexo
Theme - NexT.Pisces
| Total visited times